EF连表查询
作者:互联网
EF连表查询
public ActionResult list() { //如果想N张表,再向db.BusinessPress后面加 var data = db.Business.Join(db.BusinessPress, b => b.BPress, p => p.ID, (b, p) => new { ID = b.ID, BName = b.BName, BPress = p.PName, Price = b.Price, }).ToList(); //ViewModel List<VMBusiness> list = new List<VMBusiness>(); data.ForEach(item => { list.Add(new VMBusiness() { ID = item.ID, BName = item.BName, BPress = item.BPress, Price = item.Price, }); }); return View(list); }
标签:BPress,Price,EF,list,查询,连表,item,BName,ID 来源: https://www.cnblogs.com/mvpbest/p/13460254.html