views:

21

answers:

0

I'm currently working on my first Linq-to-Sql app. I've implemented the data-access methods with a short dataContext lifetime like this:

public IProduct GetByCode(string code)
{
   using (var db = new dataContext())
   {
      return db.Products.SingleOrDefault(e => e.Code == code);
   }
}        

I'm wondering how to get change notifications of clr-properties. When you have a single dataContext this is not a problem.

So the question is: How do I get in-memory changes of an entity?!

I have an entity which can be modified in two different screens. Updates in one screen should be visible in the other. The only possibility I see is to let the dataContext have the same lifetime as both screens, wich comes down to application lifetime.

I feel friction between the Unit of Work pattern (per request) and full databinding capabilities. Please tell me what I'm missing...