[转]Linq to sql 实现多条件的动态查询(方法二)

  1. var query = from f in db.TField 
  2.                             join fw in db.TFieldWel 
  3.                             on f.emp_no equals fw.emp_no 
  4.                             where f.fy_no == fy_no && fw.fy_no == fy_no 
  5.                             && (string.IsNullOrEmpty(brd_no) ? true : f.brd_no.Equals(brd_no)) 
  6.                             && (string.IsNullOrEmpty(area_no) ? true : f.area_no.Equals(area_no)) 
  7.                             && (string.IsNullOrEmpty(city_no) ? true : f.city_no.Equals(city_no)) 
  8.                             && (string.IsNullOrEmpty(outlet_no) ? true : f.city_no.Equals(outlet_no)) 
  9.                             select new
  10.                                 f.area_no,f.brd_no,f.city_no,f.emp_name,f.emp_no,f.f_ft,f.usr_no, 
  11.                                 fw.we_no, fw.we_money 
  12.                             }; 

 

posted @ 2013-01-22 10:29  louiskoo  阅读(200)  评论(0编辑  收藏  举报