首页 > 代码库 > linq to object多条件综合查询
linq to object多条件综合查询
/// <summary>
/// 月计划项目多条件综合查询
/// </summary>
/// <param name="deptID">部门ID</param>
/// <param name="year">年</param>
/// <param name="month">月</param>
/// <param name="type">类型</param>
/// <param name="name">名称</param>
/// <param name="isFinished">是否完成</param>
/// <returns></returns>
public List<DTO_DeviceMaintain_Project> GetMonthPlanProjectList(Guid? deptID, int? year, int? month, string type, string name, bool? isFinished)
{
monthPlanRepository.SetContext(projectRepository.Context);
var list = from a in projectRepository.All()
join b in monthPlanRepository.All()
on a.PlanID equals b.ID
where a.Month == null &&
deptID == null ? true : b.DeptID == deptID &&
year == null ? true : b.Year == year &&
month==null? true:b.Month==month &&
type==null? true:a.Type==type &&
name==null? true:a.Name.Contains(name) &&
isFinished==null? true:a.IsFinished==isFinished
select new DTO_DeviceMaintain_Project
{
Amount = a.Amount,
Code = a.Code,
CreateDate = a.CreateDate,
CreateUserID = a.CreateUserID,
CreateUserName = a.CreateUserName,
ID = a.ID,
IsFinished = a.IsFinished,
ModifyDate = a.ModifyDate,
ModifyUserID = a.ModifyUserID,
ModifyUserName = a.ModifyUserName,
Month = a.Month,
Name = a.Name,
PlanID = a.PlanID,
Remark = a.Remark,
Superintendent = a.Superintendent,
TotalPrice = a.TotalPrice,
Type = a.Type,
Unit = a.Unit,
UnitPrice = a.UnitPrice
};
return list.ToList();
}
linq to object多条件综合查询