码迷,mamicode.com
首页 > 其他好文 > 详细

linq to object多条件综合查询

时间:2014-11-05 12:33:29      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:style   color   ar   os   sp   on   bs   amp   new   

        /// <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多条件综合查询

标签:style   color   ar   os   sp   on   bs   amp   new   

原文地址:http://www.cnblogs.com/chengxuyuandadao/p/4075873.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!