Answer the question
In order to leave comments, you need to log in
LINQ and big table, how to solve Count problem?
Can't solve problem with collection size calculation. There is a table on the site with filters, 10 records are displayed there.
data = dc.books.OrderBy(x => x.id).Where(x =>
(market_id == 0 || x.market_id != 0 && x.market_id == market_id)
&& (name == null || x.name != null && (x.name.StartsWith(name)))
&& (author == null || x.author != null && (x.author.StartsWith(author)))
).Skip(param.Start).Take(10).ToList();
count = db.books.Count(x =>
(market_id == 0 || x.market_id != 0 && x.market_id == market_id)
&& (name == null || x.name != null && (x.name.StartsWith(name)))
Answer the question
In order to leave comments, you need to log in
Can AsNoTracking speed up query execution?
count = db.books.AsNoTracking().Count(x =>
(market_id == 0 || x.market_id != 0 && x.market_id == market_id)
&& (name == null || x.name != null && (x.name.StartsWith(name)))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question