I used the following static compiled query to retrieve Product object from
our database:
private static readonly Func<MyDBDataContext, int, IQueryable<Job>>
StaticCompiledQuery = CompiledQuery.Compile((MyDBDataContext dbContext,
int productID) =>
from p in dbContext.Products
where p.ProductID == productID
select p);
StaticCompiledQuery(dbContext, productID).SingleOrDefault()
If an object is retrieved using static compiled query it can be updated only
once when it first time loaded into the DataContext. After that any changes
to the objects retrieved using the same compiled query are ignored, namely
you can change any field of the retrieved object in the memory but the
changes are not saved in the database after SubmitChanges(). This makes
static compiled queries totally unpractical!
Any help will be much appreciated!