ASP.net 动态数据 - OnPropertyChanging 不更新其他列
这是我的代码:
partial void OnisApprovedChanging(bool value)
{
this.dateApproved = DateTime.Now;
}
“dateApproved”在业务逻辑中更新,但此更改未应用于数据库表。 我见过一些示例,其中每当对表进行任何编辑时都会更新 DateUpdated 列,但我只对此字段更新时更新时间戳感兴趣,并且我不确定访问该字段的最佳方式DataContext 来自此范围。
我需要实例化数据上下文并手动更新吗?
编辑做了一些更多的研究,发现一些博客建议在更新时添加业务逻辑,如下所示:
public partial class DataContext : System.Data.Linq.DataContext
{
partial void Updateaccount(account instance)
{
//business logic here
}
}
但是,我无法确定任何方法来查明特定字段是否已更改。 有任何想法吗?
Here is my code:
partial void OnisApprovedChanging(bool value)
{
this.dateApproved = DateTime.Now;
}
'dateApproved' is updated in the business logic, but this change is not being applied to the database table. I've seen some examples where DateUpdated columns are updated whenever any edit to a table is made, but I'm only interested in updating the time-stamp when this field is updated and I'm not sure of the best way to access the DataContext from this scope.
Do I need to instantiate the Data-context and update it manually?
EDIT Did some more research, and found that some blogs suggested adding business logic on update like this:
public partial class DataContext : System.Data.Linq.DataContext
{
partial void Updateaccount(account instance)
{
//business logic here
}
}
However, I cannot determine any way to find out if particular fields have changed. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发现这是获取原始实体并进行比较的方法。
Found this is the way to get the original entity and do comparisons.