質問

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!

役に立ちましたか?

解決 2

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

他のヒント

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top