Lambda 表达式 Where 子句
Lambda expression Where clause
Linq convert into SQL query get value where clause context.purposes.tolist
(id=4000 into 4050) 是怎么回事?
public ActionResult Index()
{
PurposeModel model = new PurposeModel();
using (DAL.db_Hajj_UmrahEntities context = new DAL.db_Hajj_UmrahEntities())
{
List<DAL.Purpose> purposelist = context.Purposes.ToList();
model.PurposeList = purposelist.Select(x => new SelectListItem()
{
Text =x.PurPose1,
Value=x.Id.ToString()
});
}
return View(model);
}
我想这就是您要找的
context.Purposes.where(s=>s.id>=4000 && s.id<=4050).ToList();
model.PurposeList = purposelist.Where(y => y.ID >= 4000 && y.ID <= 4050)
.Select(x => new SelectListItem()
{
Text =x.PurPose1,
Value=x.Id.ToString()
})
.ToList();
Linq convert into SQL query get value where clause context.purposes.tolist
(id=4000 into 4050) 是怎么回事?
public ActionResult Index()
{
PurposeModel model = new PurposeModel();
using (DAL.db_Hajj_UmrahEntities context = new DAL.db_Hajj_UmrahEntities())
{
List<DAL.Purpose> purposelist = context.Purposes.ToList();
model.PurposeList = purposelist.Select(x => new SelectListItem()
{
Text =x.PurPose1,
Value=x.Id.ToString()
});
}
return View(model);
}
我想这就是您要找的
context.Purposes.where(s=>s.id>=4000 && s.id<=4050).ToList();
model.PurposeList = purposelist.Where(y => y.ID >= 4000 && y.ID <= 4050)
.Select(x => new SelectListItem()
{
Text =x.PurPose1,
Value=x.Id.ToString()
})
.ToList();