Metadatatype support ?

Feb 26, 2009 at 10:40 AM
Is it possible to put attributes on a MetadataType class ?

[MetadataType(typeof(PersonMetaData))]
public class Person
{
  public string Name {get;set;}
}

public class PersonMetaData
{
  [NotNull]
  public string Name { get;set; }
}

Because in Linq 2 SQL, classes and properties are generated and attributes can not easily be added ???
Coordinator
Mar 3, 2009 at 5:52 PM
Sorry, I don't have any direct experience with MetadataType classes so I can't answer your question. You could always programmatically register validators on the properties:

typeof(PersonMetaData).GetProperty("Name").AddValidation(new [] {new NotNull()});