LINQ Custom Entity Object Validation

  • Thread starter Thread starter Mike P
  • Start date Start date
M

Mike P

I am working through this tutorial :

http://weblogs.asp.net/scottgu/archive/2007/07/11/linq-to-sql-part-4-upd
ating-our-database.aspx

and trying to get this code to work :

using System;

public partial class Order
{
partial void OnValidate()
{
if (RequiredDate < OrderDate)
{
throw new Exception("Deliver date is before order date!");
}
}
}

But I am getting this error :

No defining declaration found for implementing declaration of partial
method 'Order.OnValidate()'

Can anybody help with this?
 
It looks like the designer now generates:

partial void OnValidate(System.Data.Linq.ChangeAction action);

so you need to add this argument for it to work. Alternatively, if you
type "partial" (and hit space) intellisense should prompt the available
options and create the stub for you.

Marc
 
Back
Top