Question

is it possible to map an ActiveRecord class using the MetadataType attribute in order to keep the original class clean?
I have tried the following code but it didn't work:

[MetadataType(typeof(UserMetadata))]
public class User : ActiveRecordBase<User>
{
    public int Id { get; set; }
    public string UserName { get; set; }
    public string Password { get; set; }
}

[ActiveRecord("Users")]
public class UserMetadata
{
    [PrimaryKey("ID")]
    public int Id { get; set; }

    [Property(Unique = true)]
    public string UserName { get; set; }

    [Property]
    public string Password { get; set; }
}

ActiveRecord is simply not loading the mapping. I have also tried other combinations of attributes but none of them worked.
Is it possible?

Thanks!

Était-ce utile?

La solution 2

Not really a definitive solution, but I ended up using a partial class to clean my code.

Autres conseils

You may be able to try it with AutoMapper: http://automapper.org/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top