JHA*_*JHA 3 .net linq linq-to-sql
你们有没有人能告诉我如何完成以下任务?
// Prepare object to be saved
// Note that MasterTable has MasterTableId as a Primary Key and it is an indentity column
MasterTable masterTable = new MasterTable();
masterTable.Column1 = "Column 1 Value";
masterTable.Column2 = 111;
// Instantiate DataContext
DataContext myDataContext = new DataContext("<<ConnectionStrin>>");
// Save the record
myDataContext.MasterTables.InsertOnSubmit(masterTable);
myDataContext.SubmitChanges();
// ?QUESTION?
// Now I need to retrieve the value of MasterTableId for the record just inserted above.
Run Code Online (Sandbox Code Playgroud)
亲切的问候
在调用SubmitChanges之后,将为插入的对象分配标识值.
只需访问:
masterTable.MasterTableId
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1269 次 |
| 最近记录: |