我有以下课程
public class InvestorsLottery : Lottery
{
[Column(TypeName = "decimal(14, 2)")]
public decimal Investment { get; set; }
[Required]
public int Percentage { get; set; }
[Required]
[Column(TypeName = "decimal(30, 18)")]
public decimal InvestmentEth
{
get { return _investmentEth; }
set {
_investmentEth = Investment / EthPrice;
value = _investmentEth
}
}
private decimal _investmentEth;
}
使用以下流利的api
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<InvestorsLottery>()
.Property(p => p.InvestmentEth)
.HasField("_investmentEth")
.UsePropertyAccessMode(PropertyAccessMode.Field);
}
但是 InvestmentEth 的价值保持为零——我该如何改变呢?