首页 > 代码库 > linq contain和orderby

linq contain和orderby

var data = http://www.mamicode.com/from px in db.vw_ygpx
// orderby px.ygid descending
select px;

if (!string.IsNullOrEmpty(key))
{
key = key.Trim();
// data = http://www.mamicode.com/data.Where(d => d.ygmc.Contains(key) || d.gh.Contains(key));
data = http://www.mamicode.com/from d in data
where d.ygmc.Contains(key) || d.gh.Contains(key)
//where SqlMethods.Like(d.ygmc , "%肖%")

select d ;
}

var res=(from d in data
select d).AsEnumerable().OrderByDescending(d => d.ygid).Skip((pageIndex - 1) * pageSize).Take(pageSize);
return JsonHelper.ToJson(res);//这是一个未解之迷,当不加AsEnumerable()时就会报丢失字段,当where d.ygmc.Contains(key) 直接写成where d.ygmc.Contains("肖")时又不会报错

linq contain和orderby