1

I have a large dataset in my Entity Framework context - table1 and a large List<T>, I need to count same values in the table1/list1 above.

I can do it two different ways:

  1. jointCollection=table1.union(list1) - and to check: the value of list1.count+table1.count-jointCollection.count...
  2. to do count on select table1 with multi condition(list1.count)

My question is which method is more efficient?

2
  • Please define "in my context"? Are you trying to be smart by loading the complete table into memory instead of doing what is sensible, i.e. asking the database to count them? Commented Jul 28, 2012 at 8:29
  • my context is my complete table... guessing by your replay it is not that smart... Commented Jul 28, 2012 at 12:05

1 Answer 1

3

The best solution is to run SQL profiler while you run each one and find out!

However, if efficiency is paramount, I would recommend using a stored procedure imported in to EF as a function, as Linq to Entities adds additional overhead.

Sign up to request clarification or add additional context in comments.

1 Comment

That implies and assumes he's using SQL Server ... which is likely, but not clear from the question.... EF works against other RDBMS systems, too

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.