有两个表
FeatureComparision
FKFeatureId FKHandsetId Value
29 208 207MP
46 208 upto 11h
功能
PKFeatureId FeatureName DisplayInOverview SortOrder
29 Focus 1 1
46 StandBy 1 2
//DisplayInOverview column is of type bit
sql所需的输出是
select f.featurename,fc.Value
from FeatureComparision fc
join Feature f on fc.FKFeatureId = f.PKFeatureId
Where fc.FKHandSetId = 208 and f.DisplayInOverview=1
order by f.SortOrder
和linq是
var Specs = from fc in objCache.LstFeatureComparisions
join f in objCache.LstFeatures
on fc.FKFeatureId equals f.PKFeatureId
where (fc.FKHandSetId == 208 && f.DisplayInOverview == true)
select new
{
f.FeatureName,
fc.Value
};
如何在此linq
中进行类似sql的排序答案 0 :(得分:2)
添加orderby
字符串:
var Specs = from fc in objCache.LstFeatureComparisions
join f in objCache.LstFeatures
on fc.FKFeatureId equals f.PKFeatureId
where (fc.FKHandSetId == 208 && f.DisplayInOverview)
orderby f.SortOrder ascending
select new
{
f.FeatureName,
fc.Value
};