ef动态拼接查询字段
ef动态拼接查询字段可以使用委托的方式Func
Func<Sc_V_PersonalInspectionTableSchema, WhereClip> whereExp = p =>
{
var whereClip = WhereClip.All;
if (PlanBeginTime!=null)
{
whereClip = whereClip && p.PlanBeginTime == PlanBeginTime;
}
if (PlanEndTime!=null)
{
whereClip = whereClip && p.PlanEndTime == PlanEndTime;
}
if (!string.IsNullOrEmpty(ProjectName))
{
whereClip = whereClip && p.GroupName.Contains(ProjectName);
}
return whereClip;
};
var list = DataAccess.LepulsDB.DBContext.Sc_V_PersonalInspection.Select().Where(whereExp).ToList();

浙公网安备 33010602011771号