Search code examples
c#linq-to-sqlpartial-classes

Override the setter generated in the DBML file


I want to override a setter of a property in a partial class:

Partial class:

public partial class User
{
    public string Name
    {
        set
        {
            // Do something
        }
    }
}

but I have the following error:

The type 'User' already contains a definition for 'Name'

How can I modify the initial setter generated in the DBML file?


Solution

  • It is possible, just by employing some trickery

    See http://www.codeproject.com/Articles/31519/LINQtoSQL-Customize-the-Code-Generated-by-the-Desi

    This question could be of interest for you, too: DBML customization vs regeneration

    You have not specified what sort of customization you want to achieve, though.