0
以下行不起作用,因爲distinct()不提供有序輸出。LINQ中的orderby()和distinct()
var context= new BatchEntities();//Entity model
var practices = (from p in context.EMSCAN_BATCH orderby p.PRACTICE select p.PRACTICE).Distinct();
嘗試這樣做:
var practices = (from p in context.EMSCAN_BATCH
select p.PRACTICE).Distinct().OrderBy(x=>x.PRACTICE);
這給了錯誤的字符串不包含定義 '實踐' .... 也試過這樣:
var practices =(from p in context.EMSCAN_BATCH
select new
{
p.PRACTICE
}).Distinct().OrderBy(x=>x.PRACTICE);
這給了錯誤的輸出。