public long CreateUser(UserEntity user) { using (var context = new IzumiContext("CodeFirstDb")) { Func <long> func = () => { long UserID = Snowflake.Instance().GetId(); user.UserID = UserID; context.User.Add(user); context.SaveChanges(); return(UserID); }; return(ExcuteTransaction(context, func)); } }
public long CreateStudent(StudentEntity student) { using (var context = new IzumiContext("CodeFirstDb")) { Func <long> func = () => { long studentID = Snowflake.Instance().GetId(); student.StudentID = studentID; context.Student.Add(student); context.SaveChanges(); return(studentID); }; return(ExcuteTransaction(context, func)); } }
public long UpdateStudent(StudentEntity studentEntity) { using (var context = new IzumiContext("CodeFirstDb")) { Func <long> func = () => { DbEntityEntry <StudentEntity> entry = context.Entry <StudentEntity>(studentEntity); entry.State = EntityState.Unchanged; entry.Property(t => t.StudentID).IsModified = false; entry.Property(t => t.StudentName).IsModified = true; entry.Property(t => t.Status).IsModified = true; context.SaveChanges(); return(studentEntity.StudentID); }; return(ExcuteTransaction(context, func)); } }