Entities as Linq: Counting takes a long time.

c# entity-framework linq

Question

I need to have parent and parent.child.count()....in the query.. when i do this it is taking 20 seconds....its not a huge database...Any ideas for optimization...

var plist = context.persons
  .Select(p => new
  {
    p.fullName,
    c.personID,
    p.Status,
    p.Birthdate,
    p.Accounts.Count
  }).ToList();
1
3
11/16/2010 9:39:10 PM

Popular Answer

Here is a great article on using count() when you really meant to use any()

http://blogs.teamb.com/craigstuntz/2010/04/21/38598/

4
11/16/2010 8:30:17 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow