地圖數據庫字段在你的類只讀屬性:
Map(x => x.IsEvenSide);
Map(x => x.IsOddSide);
並通過公共屬性來控制他們:
public class Example
{
public IsEvenSide { get; private set; }
public IsOddSide { get; private set; }
public SideOfStreet SideOfStreet
{
get
{
var side = SideOfStreet.None;
if (IsEvenSide) { side |= SideOfStreet.Even; }
if (IsOddSide) { side |= SideOfStreet.Odd; }
return side;
}
set
{
IsEvenSide = (value & SideOfStreet.Even) == SideOfStreet.Even;
IsOddSide = (value & SideOfStreet.Odd) == SideOfStreet.Odd;
}
}
}
[修訂版的標誌枚舉工作]
如果您不想爲IsEvenSide和IsOddSide公開getter,您可以將它們標記爲private,並使用Reveal:
Map(Reveal.Property<Example>("IsEvenSide"));
哎呀,糾正了這個問題。我從內存中輸入我的問題 - 真正的系統沒有Both選項並且使用標誌。 –