How to encode partial extensions that Linq to SQL auto-generates?

I created a class from Linq to SQL Clasees with VS 2008 SP1 Framework 3.5 SP1, in which case I expanded the partial

partial void UpdateMyTable(MyTable instance){ // Business logic // Validation rules, etc. } 

My problem is when I execute db.SubmitChanges (), it executes UpdateMyTable and does checks, but it does not update, I get this error:

 [Exception: Deliver] System.Data.Linq.ChangeProcessor.SendOnValidate(MetaType type, TrackedObject item, ChangeAction changeAction) +197 System.Data.Linq.ChangeProcessor.ValidateAll(IEnumerable`1 list) +255 System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) +76 System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode) +331 System.Data.Linq.DataContext.SubmitChanges() +19 
+4
source share
2 answers
  • if you provide this method, you must upgrade in the method.

http://msdn.microsoft.com/en-us/library/bb882671.aspx

  • If you implement the Insert, Update, and Delete methods in your partial class, the LINQ to SQL runtime will call its own default methods instead of calling SubmitChanges.

Try MiTabla.OnValidate

+3
source

If you want to implement this method, but do not perform the update yourself, you call the ExecuteDynamicUpdate (item) method call;

Similarly ExecuteDynamicDelete and ExecuteDynamicInsert for DeleteMyTable and InsertMyTable respectively.

+1
source

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


All Articles