读书人

entity framework code first many to

发布时间: 2013-04-09 16:45:09 作者: rapoo

entity framework code first many to many add/update/delete/select
entity framework code first many to many add/update/delete/select求实例讲解,主要是删除,不要什么级联删除,要代码实现(include)。最好是三个表以上。


select d).Single();

student.Courses.Add(new Course() { Name = "Computer Science"} );
context.SaveChanges();

//Assert.AreEqual(0, context.Husbands.Where(x => x.Name == "A").Count());
Assert.AreEqual(3, context.Courses.Count());
}

//Delete
using (var context = new BreakAwayContext())
{
var student = (from s in context.Students
where s.Name == "Ray"
select s).Single();

context.Students.Remove(student);
context.SaveChanges();
Assert.AreEqual(0, context.Students.Where(x => x.Name == "Ray").Count());
}

读书人网 >asp.net

热点推荐