M
MarkA
Hi, I have been using EF since it's release, for the most part, it's saved me
thousands of lines of code.
I've a scenario I havn't been able to solve with well performing code.
Imagine a model of a phone book, with Companies, Departments and People. A
company has an ID and name, department has an ID and name, and a person has
an ID and name (keeping it simple).
How can I write an entities statement which will return a collections of all
people under a company (regardless of department)?
I considered using something like this:
context.People.Where(p=>p.Department.Company.CompanyId == CompanyIdSearched)
However, my understanding is this goes back to the database to pull the data?
I need to query based on the in-memory data, so I can include data which has
changed but not yet been saved (eg. to check if I've already added a Person
in an import).
What's the most efficient way to query the in-memory context, to get all
People who work for a Company?
Thanks in advance
+M
thousands of lines of code.
I've a scenario I havn't been able to solve with well performing code.
Imagine a model of a phone book, with Companies, Departments and People. A
company has an ID and name, department has an ID and name, and a person has
an ID and name (keeping it simple).
How can I write an entities statement which will return a collections of all
people under a company (regardless of department)?
I considered using something like this:
context.People.Where(p=>p.Department.Company.CompanyId == CompanyIdSearched)
However, my understanding is this goes back to the database to pull the data?
I need to query based on the in-memory data, so I can include data which has
changed but not yet been saved (eg. to check if I've already added a Person
in an import).
What's the most efficient way to query the in-memory context, to get all
People who work for a Company?
Thanks in advance
+M