I validate data for a table made in the linq designer in the event OnValidate.
This event is fired when I insert records, but not is fired when I update records.
I have this code:
public bool Save(int id, string marca, string modelo, string año, string motor,
bool disponible, RuleList issues)
{
Usado u;
if (id == 0)
{
u = new Usado();
u.IdUsado = GetNextIdUsado();
u.FechaCreacion = DateTime.Now;
}
else
{
u = GetUsadoById(id);
}
u.Marca = marca;
u.Modelo = modelo;
u.Año = año;
u.Motor = motor;
u.Disponible = disponible;
if (id == 0)
{
DataBase.Usados.InsertOnSubmit(u);
}
return Execute(issues, DataBaseOperation.Save);
}
When id is equal to zero I do an insert, otherwise I do an update.
Why might this happen? Thank you in advance for any clue.