none
apply validation on linq to sql generated code ??? RRS feed

  • Question

  • Hi.
    I add a linq to sql class to my project and drag and drop some tables onto it. After that I have a linq-sql generated code
    which includes classes corressponding with entities in database and these classes implement 2 interfaces INotifyPropertyChanged, INotifyPropertyChanging.
    I want to ask Can i add code to property of class(setter) so that I can use validation mechanism on my databound control ?
    If I can, can you tell me how or give me resources.
    And why these classes need to implement INotifyPropertyChanging anyway, what situations it comes to handy
    Thanks.
    Wednesday, February 10, 2010 7:36 PM

Answers


  • There are many partial methods that you can provide to perform custom validation and other operations.  Take a look at the designer created code file and look for "Extensibility Method Definitions".  You'll find a section for each class with methods such as OnLoaded(), OnValidate(), OnCreated(), and separate methods for when each property is changing/changed.  You can provide the code for these methods in a separate code file to do whatever you need.

    Monday, February 15, 2010 8:08 PM