此代码狙击手来自使用 Entity Framework 5 Code First 将 CreatedDate 添加到实体
public override int SaveChanges()
{
DateTime saveTime = DateTime.Now;
foreach (var entry in this.ChangeTracker.Entries().Where(e => e.State == System.Data.EntityState.Added))
{
if (entry.Property("CreateDate").CurrentValue == null)
entry.Property("CreateDate").CurrentValue = saveTime;
}
return base.SaveChanges();
}
但在我的解决方案中,我收到此错误“System.Collection.Generic.IEnumerable 'Does not contain a definition for Where ...