5
나는 다음과 같은 코드가 작동하지 않습니다LINQ - 동적 ORDERBY 절은
//build query
var shops = (from p in dataContext.shops
let distance = dataContext.GetDistance(p.lat, p.lon, nearlat,nearlon)
join c in dataContext.shops_category on p.id equals c.poi_id
select new ShopsModel { p = p, distance = distance }
);
}
//add dynamic orderby
if(somthig)
shops.OrderBy(distance)
else
shops.OrderBy(p.name)
//get records.
return shop.Take(30).ToList()
그건이있는 OrderBy를 제외하고 잘 작동합니다. 생성 된 SQL 코드에는 orderby 절이 없으며 레코드는 정렬되지 않습니다.
아이디어가 있으십니까? 도와 주셔서 감사합니다.