J
Julie
I have a situation where I have many methods that have a similar linq
expression. Is there a way to re-write to be more efficient?
int Qty1()
{
return (from each in MyData where each.Item1 == 1 select each).Count();
}
int Qty2()
{
return (from each in MyData where each.Item2 == 1 select each).Count();
}
int Qty3()
{
return (from each in MyData where each.Item3 == 1 select each).Count();
}
etc.
What I'd like is a generic Qty method that takes the 'where' condition:
int Qty(??? condition)
{
return (from each in MyData where condition select each).Count();
}
But I have no idea how to do this.
Thanks!
expression. Is there a way to re-write to be more efficient?
int Qty1()
{
return (from each in MyData where each.Item1 == 1 select each).Count();
}
int Qty2()
{
return (from each in MyData where each.Item2 == 1 select each).Count();
}
int Qty3()
{
return (from each in MyData where each.Item3 == 1 select each).Count();
}
etc.
What I'd like is a generic Qty method that takes the 'where' condition:
int Qty(??? condition)
{
return (from each in MyData where condition select each).Count();
}
But I have no idea how to do this.
Thanks!