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

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -