Adding DataAnnontations to Generated Partial Classes

Posted by Naz on Stack Overflow See other posts from Stack Overflow or by Naz
Published on 2009-08-05T10:51:47Z Indexed on 2011/01/08 0:54 UTC
Read the original article Hit count: 269

Hi

I have a Subsonic3 Active Record generated partial User class which I've extended on with some methods in a separate partial class.

I would like to know if it is possible to add Data Annotations to the member properties on one partial class where it's declared on the other Subsonic Generated one I tried this.

public partial class User
{
    [DataType(DataType.EmailAddress, ErrorMessage = "Please enter an email address")]
    public string Email { get; set; }

    ...
}

That examples gives the "Member is already defined" error.

I think I might have seen an example a while ago of what I'm trying to do with Dynamic Data and Linq2Sql.

© Stack Overflow or respective owner

Related posts about validation

Related posts about subsonic