Hi using the kendo ui grid in my project.
This is my code to include a record in the database.
Enter the public static zero (scholarship model student) {student.StudentId = all (). OrderByDescending (p = & gt; P. StudentID). first (). Student id + 1; //All().Instert (0, student); UniGranti UniGuentits = New Ungroup (); Student Stu = new student (); Stu.FName = student.FirstName; Stu.LN name = student.lostname; Stu.Gender = uniRegEntities.Genders.Where (x => x.Title == StudentGender). FirstOrDefault (); Stu.Id = student.StudentId; UniRegEntities.Students.Add (stew); UniRegEntities.SaveChanges (); } And this is my update statement.
Public Static Zero Update (Scholarship Model Student) {UNITED VENTURE REFERENCES = NEW UNIVERSITY (); Var studentToUpdate = context.Students.Where (x => x.Id == Student student ID). FirstOrDefault (); StudentToUpdate.FName = Students. first name; StudentToUpdate.LName = Student.Lostname; StudentToUpdate.Gender = context.Genders.Where (x => x.Title == student.generator). FirstOrDefault (); Context.SaveChanges (); } Can anyone recommend me the removal method?
You can either get a unit from DB and then remove it or make one And then remove it.
Like this:
var e = // Get ctx.DeleteObject (e); Ctx.SaveChanges (); or
var e = new fu () {FooId = id}; Ctx.Entity.Attach (E); Ctx.DeleteObject (E); Ctx.SaveChanges (); Applies to your situation:
You are receiving a record so that you DeleteObject () Public Static Zero Update (Scholarship Model Student) {UNITRICTITY REFERENCES = NEW UNIVERSITY (); Var StudentTodetlet = Reference student. Where (x => x.id == student student ID). FirstOver Default (); Context.Students.DeleteObject (studentToUpdate); Context.SaveChanges (); }
No comments:
Post a Comment