Tag: updatecheck

使用DataContext Attach方法更新实体时更新检查’问题

我正在尝试在通用存储库中创建一个更新方法作为LINQ to SQL数据访问层。 我有这样一个实体: [Table] public class Product { [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = “Int NOT NULL IDENTITY”)] public int Id { get; private set; } [Column(UpdateCheck = UpdateCheck.Never)] public string Name { get; set; } …. } 我为所有为id执行的字段设置了Update Check = true @jeff Atwood在这篇文章中建议我将attach方法中的asModified属性设置为true,我在本文中发现如下: public void Update(T entity) { _db.GetTable().Attach(entity, true); _db.SubmitChanges(); […]