ASP.NET アプリケーションで DetailsView と共に EntityDataSource を使用しています。レコードを挿入した後に ID 列の値を取得したい。ObjectDataSource には e.ReturnValue プロパティがあります。EntityDataSource で同等のものを知りたいですか?
1 に答える
1
InsertedであるイベントにサブスクライブできますEventHandler<EntityDataSourceChangedEventArgs>。
インスタンスにはEntityDataSourceChangedEventArgs、新しく挿入されたエンティティを表す Entity プロパティがあります。
void EntityDataSource1_Inserted(object sender, EntityDataSourceChangedEventArgs e) {
YourEntityType newlyAdded = (YourEntityType)e.Entity;
int newId = newlyAdded.Id;
}
于 2011-12-23T04:08:18.823 に答える