There is an entity Projects. Each element of this entity is of type Project.
From the neighboring database I create a List<Project>
via a DataReader (since there is no Entity Framework on that base) and I want to make a comparison with my entity.
I need to get items that are in my essence, but not in the neighboring database.
I tried to do this thing:
var delProjects = db.Projects.Except(listProjects).ToList();
But the error takes off:
An unhandled exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll
Additional information: Unable to create a value of type 'WCFConsoleServer.Models.Project'. Only primitive types or enumeration types are supported in this context.
Actually the question is how to avoid this error?
I think that the problem should be solved if the whole entity is loaded into memory in the List and only then do the subtraction of the set. But isn’t the performance going to be strong?
You can obviously shoot all this in the foreach and compare, but it seems to me too slowly.
Are there any other solutions?
upd
Such a construction produces a similar error.
db.Projects.Where(z=>!listProjects.All(y=>y.id!=x.id)).ToList();
Although it should be interpreted, in my opinion, as
foreach foreach if