c# - Linq Query with a where condition - count items -
how can change request :
query = query.where(item => (from table in context.table table.amount == item.amount select table).count() >= 10);
to not use subquery (from ... in ...)
?
i tried create subquery separately, use condition :
var subquery = table in context.table select table.amount;
var list = subquery.tolist()
but don't know how can use after that, because of .count()
operation.
thank comments.
how this:
query = query.where(item => context.table .count(t => t.amount == item.amount) >= 10);
or reduce number of round-trips:
var counts = context.table .groupby(t => t.amount) .select(g => new {amount = g.key, count = g.count()}); query = q in query join c in counts on q.amount equals c.amount c.count >= 10 select q;
Comments
Post a Comment