Student student = CurrentDal.AddEntity(student entity);
classentity.student Id = student .id;
CurrentDB .classentityDal.AddEntity(classentity);
return CurrentDBSession.SaveChange ();
好像取不了student .id
classentity.student Id = student .id;
CurrentDB .classentityDal.AddEntity(classentity);
return CurrentDBSession.SaveChange ();
好像取不了student .id
解决方案
20
Student student = …;
classentity.student = student ;
CurrentDB .classentityDal.AddEntity(classentity);
return CurrentDBSession.SaveChange ();
classentity.student = student ;
CurrentDB .classentityDal.AddEntity(classentity);
return CurrentDBSession.SaveChange ();
10
持久化前肯定是不知道那个自增值是什么的,题主不用想了。假如你非要知道写数据库后的自增值是什么,很简单啊。
Student student = CurrentDal.AddEntity(student entity); classentity.student Id = student .id; CurrentDB .classentityDal.AddEntity(classentity); CurrentDBSession.SaveChange (); return student.id
10
EF 教程上教你怎么写,你就学习它的做法。不要心机太重,要先学会简单、正规的东西。