Lose data binding capabilities with the UoW template in Linq to Sql

I am currently working on my first Linq-to-Sql application. I implemented dataContext short-lived data access methods as follows:

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

I am wondering how to get notified of clr property changes. When you have one dataContext, this is not a problem.

So the question is: how do I get changes in the memory of an object ?!

I have an object that can be changed on two different screens. Updates on one screen should be visible in another. The only opportunity I see is to allow the DataContext to have the same lifetime as the screens that are about to expire.

I feel friction between the Unit of Work pattern (on request) and the ability to fully bind data. Please tell me what I am missing ...

+3
1

LINQ to SQL INotifyPropertyChanged, .

, , ( :?).

, : WPF/Silverlight , MVVM, .

0

Source: https://habr.com/ru/post/1756451/


All Articles