Hello,
I am currently using Linq To Sql classes in my project, and I am implementing validation, but I am having a problem trying to create a generic validation class that I can use with the Linq To Sql classes.
Specifically, I have a class named Contact - that has been generated automatically by Linq To Sql. So I can't change anything in it. But as it is a partial class I created another partial Contact that I want to perform validation in.
In my partial Contact class I want to provide a partial method called OnValidate where it will do validation specific to the Contact class object. (I have this working so far)
But in an effort to make my system more generic I would like my partial Contact class to inherit from a generic validation class, where it provides the base OnValidate method, and my partial Contact class overrides it, should specific validation be required.
The problem I am having is I am not sure what access modifier I need to create on the class and methods of my validation class for this scenario to work.
Below is the general structure, I hope someone can see what I need to fix:
-
public partial class Contact : INotifyPropertyChanging, INotifyPropertyChanged
-
{
-
partial void OnValidate(System.Data.Linq.ChangeAction action);
-
}
-
-
public partial class Contact : Validation
-
{
-
// ???? Some sort of override of the validation class?
-
partial void OnValidate(System.Data.Linq.ChangeAction action)
-
{
-
// Class specific validation
-
}
-
}
-
-
????? class Validation
-
{
-
????? OnValidate(System.Data.Linq.ChangeAction action)
-
{
-
// General validation
-
}
-
}
-
Any guidance is greatly appreciated
Cheers,
Scott