views:

658

answers:

4

Hice una clase desde la herramienta Linq to SQL Clasees con VS 2008 SP1 Framework 3.5 SP1, en este caso extendí el Partial

partial void UpdateMiTabla(MiTabla instance){
   //Logica de negocio
   // Reglas de validación etc.
}

Mi problema es que cuando le doy db.SubmitChanges() si va al metodo UpdatemiTabla y hace las validaciones, pero no hace el update, dando el siguiente 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

EDIT: English Translation here

+14  A: 

Translation: How to code the partial extensions that Linq to SQL autogenerates?

I made a class from Linq to SQL Clasees with VS 2008 SP1 Framework 3.5 SP1, in this case I extended the partial

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

My problem is when I execute db.SubmitChanges(), it executes UpdateMyTable and makes the validations but it doesn't 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
Eduardo Campañó
Thanks Eduardo. That was nice.
wcm
By the way, "extensiones" va con "s"
Eduardo Campañó
+3  A: 
  • si usted proporciona este método, usted debe realizar la actualización en el método

  • if you provide this method, you must perform the update 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 them instead of its own default methods when SubmitChanges is called.

  • Si usted ejecuta el parte movible, pone al día y suprime métodos en su clase parcial, el LINQ al tiempo de pasada del SQL los llamará en vez de sus propios métodos del defecto cuando se llama SubmitChanges.


Try MiTabla.OnValidate

David B
+1  A: 

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

Likewise ExecuteDynamicDelete and ExecuteDynamicInsert for DeleteMyTable and InsertMyTable respectively.

DamienG
+2  A: 

I can't post comments; however:

http://blog.stackoverflow.com/2009/07/non-english-question-policy/

Sepulchritude
I'm sure the question asker from 1 year ago will be right along to view your "answer". -1
David B
I posted this link as a comment on the original question before seeing this answer, and before realizing that the question was a year old. +1 to offset David B's downvote.
Graeme Perrow