标签:
/// <summary> /// Linq to sql 多字段动态查询 /// </summary> /// <returns></returns> private List<TVacant> ViewBinding(ModelDataContext db,string fyno,string brd,string area,string city,string pos) { Expression<Func<TVacant, bool>> expr = n => GetCondition(n,fyno,brd,area,city,pos); var xQuery = db.TVacant.Where<TVacant>(expr.Compile()); return xQuery.ToList<TVacant>(); } private bool GetCondition(TVacant tb,string fyno,string brd,string area,string city,string pos) { bool boolResult = true; if (!String.IsNullOrEmpty(fyno)) { boolResult &= tb.fy_no == fyno; } if (!String.IsNullOrEmpty(brd)) { boolResult &= tb.brd_no == brd; } if (!String.IsNullOrEmpty(area)) { boolResult &= tb.area_no == area; } if (!String.IsNullOrEmpty(city)) { boolResult &= tb.city_no == city; } if (!String.IsNullOrEmpty(pos)) { boolResult &= tb.pos_no == pos; } return boolResult; }
标签:
原文地址:http://www.cnblogs.com/json_Chen/p/4401713.html