This question is locked. New answers and comments are not allowed.
I have a class that in the contructor I initialize an instance of IQuerable<T> from the IObjectScope.Extent<T>() and I use the IQueryable<T> for my LINQ queries.
public ConcreteRepository() |
{ |
_context = DBFactory.GetContext<T>(); |
} |
(_db is my instance of IObjectScope)
public static IQueryable<T> GetContext<T>() |
{ |
if (instance == null) |
{ |
throw new ArgumentNullException("The DBFactory has not been initialized."); |
} |
return _db.Extent<T>(); |
} |
So during the lifetime of this class I was hoping to use the same IQueryable<T>, but that returns an error. " The last accepted query piece is not from the this query." the second time that the _context is used.
Is this expected?
public virtual IQueryable<T> GetAll() |
{ |
var query = from data in _context//DBFactory.GetContext<T>() |
select data; |
return query; |
} |
This leads to my second question which is my DBFactory class has a static IObjectScope variable that is used during the
entire scope of my application. Is this ok to do or a bad idea?