0

我有一个列出所有客户的搜索屏幕。用户可以编辑一些字段(电话号码、地址等)。

在保存该“特定”记录(仅更改的记录)时,我想更新ModifiedByandModifiedOn字段。我怎样才能在代码中这样做?

我正在尝试在_Saving搜索屏幕的情况下处理此问题,但如何获取更改的行?

4

1 回答 1

2

进入表的实体设计器并单击编写代码旁边的箭头。您需要编辑两种方法,_Updating并且_Inserting. 与此类似:

C#:

partial void TableName_Updating(TableName entity)
{
    entity.ModifiedBy = this.Application.User.FullName;
    entity.ModifiedOn = DateTime.Now;
}

partial void TableName_Inserting(TableName entity)
{
    entity.ModifiedBy = this.Application.User.FullName;
    entity.ModifiedOn = DateTime.Now;
}

VB.NET:

Private Partial Sub TableName_Updating(entity As TableName)
    entity.ModifiedBy = Me.Application.User.FullName
    entity.ModifiedOn = DateTime.Now
End Sub

Private Partial Sub TableName_Inserting(entity As TableName)
    entity.ModifiedBy = Me.Application.User.FullName
    entity.ModifiedOn = DateTime.Now
End Sub
于 2012-10-23T12:44:53.753 回答