Frage

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!

War es hilfreich?

Lösung 2

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

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top