データベースのプロパティを保存しようとすると、Emitマッパーに問題が発生します。
最初に私はこのクラスをマッピングしました(それはうまくいきます):
[Serializable]
public class ProfileProperty
{
public string PropertyValue { get; set; }
public bool IsVisible { get; set; }
public ProfileProperty(string value, bool isVisible = true)
{
this.PropertyValue = value;
this.IsVisible = isVisible;
}
public ProfileProperty()
{
this.IsVisible = true;
}
}
ここにマッピングしました:
var mapper = ObjectMapperManager.DefaultInstance.GetMapper<PollmericaProfile, ProfileModel>();
ProfileModel prof = new ProfileModel();
if (x.User != null)
{
prof = mapper.Map(x);
}
ただし、一部の要件はstring
プロパティを必要としません。だから私はこれを書くことにしました:
[Serializable]
public class ProfileProperty
{
public object PropertyValue { get; set; }
public bool IsVisible { get; set; }
public ProfileProperty(object value, bool isVisible = true)
{
this.PropertyValue = value;
this.IsVisible = isVisible;
}
public ProfileProperty()
{
this.IsVisible = true;
}
public T GetValue<T>()
{
return (T)this.PropertyValue;
}
}
そして、すべてのマッピングが機能していません=(
ccanの場合は、助けてください。必要に応じて、必要な情報を提供できます
。PS正直なところ、文字列に転送して戻したいので、少なくとも機能します。
UPD:私は方法なしで試しましたpublic T GetValue<T>()
...それは動作します...