I have something like this:
public bool Function(IEnumerable<MyObject> MyObj)
{
var context = new ContextDb();
var MyObjFromContext = context.MyObjects.Where(obj => obj == MyObj) //that does not compile!
}
At commented section, i cannot do obj == MyObj comparison, because obj is a single item, and MyObj is a list of items.
So how can i obtain MyObjFromContext that is equal to MyObj, but comes from context?
You will probably have to query using the primary key:
Obviously this code assumes that your object has a “standard” integer primary key named
Id