Sorry if my question is a bit stupid, but I got really stuck with this basic thing. I have generic repository that has method like this:
protected List<T> GetEntities(Expression<Func<T, bool>> whereExpression)
{
var query = Context.Set<T>().AsQueryable();
if (whereExpression != null)
query = query.Where(whereExpression).AsQueryable();
List<T> result = query.ToList();
return result;
}
Our app should allow to work with data without commiting to database. But at any time user should be able to save changes. For adding or deleting entries I use:
Context.Set<T>().Add(entity);
and
Context.Set<T>().Remove(entity);
But after I call GetEntities deleted entities appear again and new entities does not appear. Obviosuly that GetEntities queries directly database and does not take in account local changes.
So, my question: is there any easy way to combine where-expression on data loaded from database and local changes?
Thanks.