poiuytrez
poiuytrez

Reputation: 22516

Validation and Linq

I am trying to add validation logic into my application. I have tried to follow this tutorial http://www.a2zdotnet.com/View.aspx?id=75

but I do not have any
partial void OnEmailIdChanging(string value) or any "changing" functions. in my class, so I get an error from Visual Studio. It seems that VS did not generate enough code when I have created the dbml file...

Any ideas ?

Thank you!

Upvotes: 1

Views: 114

Answers (2)

poiuytrez
poiuytrez

Reputation: 22516

I have found the solution. I was because I did not set correctly a primary key on the table !

Upvotes: 1

Arnis Lapsa
Arnis Lapsa

Reputation: 47627

Check this for partial class definition. I didn't download source (cause it asked to log in), but i`m sure that tutorial is about extending linq2sql data context with custom partial class.

namespace fooo
{

//In your case - generated linq2sql data context
public partial class foo
{
    event EmailIdChangingHandler OnEmailIdChanging;
}

//Yours partial class, which extends data context
public partial class foo
{
    public foo()
    {
        OnEmailIdChanging += doSomethingOnEmailChanging;
    }

    public void doSomethingOnEmailChanging()
    {
        Console.WriteLine("email changed");
    }
}
}

And make sure your database has column EmailId.

Upvotes: 1

Related Questions