문제

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