[LINQ]多條件關聯

多條件關聯:

            var data = (from h in context.FT_LY
                        join d in context.FT_LY_Detail
                        on new { h.Company, h.LYNo } equals new { d.Company, d.LYNo }
                        where (h.LYDate>=_DateStart) && (h.LYDate<=_DateEnd) && (h.Company==MyCompany)
                        && (string.IsNullOrEmpty(_LYNo) || h.LYNo == _LYNo)
                        && (string.IsNullOrEmpty(_Item) || d.Item == _Item)
                        && (string.IsNullOrEmpty(_ItemName) || d.ItemName == _ItemName)
                        && (string.IsNullOrEmpty(_ItemSpec) || d.ItemSpec == _ItemSpec)
                        select new
                        {
                            h.Company,
                            h.LYNo,
                            h.LYDate,
                            h.LYUser,
                            h.DeptName,
                            h.Creater,
                            h.Remark,
                            h.Audit,
                            h.Auditor,
                            h.AuditDate
                
                        });


         
            this.gdMain.DataSource = data.ToList().Distinct(); 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章