Video Tutorial Library:

LINQ to SQL 101 :

LINQtoSQL101_04_01 - Custom Validation Support

Tags: VB , Experienced , 2008 , LINQ

In this lesson we'll start looking at a few of the more advanced features of LINQ to SQL.  In this video, we'll look at how to implement custom business rule validation utilizing the Entity model's partial class and method definitions.

First off, LINQ to SQL does it's own simple validation to make sure that you are using the correct data types.  But beyond that, you'll need to implement your own business rule validation. 

Recall that when you are creating the Entity model using the design, you generate a .dbml file ... and there are two other files associated with that .dbml file ... an XML mapping file, as well as a .cs or .vb file that implements a DataContext and the Class definitions that represent the entities.  You certainly could make your own custom changes to that file, but if you ever need to re-generate the .dbml file, you'll lose all your changes. 

But the correct way to extend the Entity Model classes -- you know, the .cs or .vb file that we just talked about -- is with partial classes and partial methods.  You can just add new class files and then implement your additional functionality ...  for exaple, in this video we'll be hooking into the OnValidate partial method and the On___Completed partial method that are defined in the entity model.

We'll also look at the ChangeAction input parameter of the OnValidate() method so that we can differentiate between an update, delete or insert action.

Downloads:

Sign up today to access downloads.
LINQtoSQL101_04_01 - Custom Validation Support
Duration: 20 Minutes, 43 Seconds
Size: 23.62M
Recorded Using: Visual Studio 2008 (all versions)

Get Free Videos via Email

Sign up for our newsletter and receive links to free videos and more.

Subscribe

We don't rent/sell/or commit other evil deeds with your email address. See our Privacy Policy.