【发布时间】:2016-01-29 11:26:36
【问题描述】:
我正在我的项目中实现一个 POCO,它代表我的数据库表中的一行。我想修改构造函数中的一个值。
不幸的是,这些值似乎仅在构造函数运行之后 填充,因此我无法执行所需的逻辑。这是一个错误还是设计使然?
我可能应该提到我正在使用 Code First。
public partial class CheckpointValue
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Column("saljare")]
public int SalesAgentId { get; set; }
[Column("volym")]
public int Value { get; set; }
[Column("datum")]
public DateTime Date { get; set; }
[Column("typ")]
public string Type { get; set; }
public CheckpointValue()
{
// Values empty... Why haven't they been populated when the constructor is run?
}
}
【问题讨论】:
标签: c# .net entity-framework ef-code-first