c# - Except() on EntityCollection vs List

Using EntityFramework 4. I have an EntityCollection<SomeEntity> currentEntities with ~500k entities and a List<SomeEntity> importedEntities also with ~500k records. I want to have the list of all records occuring in currentEntities which don't exist in importedEntities.

Calling currentEntities.Select(x => x.ID).Except(importedEntities.Select(x => x.ID)) to get unique IDs of occurring records causes a System.OutOfMemoryException because it apparently loads all of the entities into the memory.

Calling currentEntities.Where(x => !importedEntities.Any(y => y.ID == x.ID)) fails with NotSupportedException ("Only primitive types ('such as Int32, String, and Guid') are supported in this context").

Is this even possible in L2E ?

Share Your Comment :)

Related Questions:
Label: [c#] [entity-framework] [linq-to-entities] [outofmemoryexception]

No comments:

Post a Comment