How do I get Id of a record without submitting and re-querying?
问题 I have an ID that is set to auto increment (int obviously). var dc = new DataContext([STRING]); var usersTable = dc.GetTable<Audit_User>(); var user = usersTable.FirstOrDefault(o => o.Username.Equals("NAME")); if (user == null) { user = new Audit_User() { Username = "NAME" }; usersTable.InsertOnSubmit(user); } //HERE - I need access to the user Id dc.SubmitChanges(); For more context, please see the tags. 回答1: //HERE - I need access to the user Id Actually you do not . If you consistently use