3
listOrders.DataSource = (from sp in dbdata.Specifications
                         join ord in dbdata.Orders on sp.O_id equals ord.O_id
                         join prd in dbdata.Products on ord.O_id equals prd.O_ID
                         where sp.Approve == "Yes" && 
                         sp.Awailable_BOM == "Yes" && 
                         prd.Hours_prd == null
                         orderby sp.O_id descending
                         select sp.O_id).Distinct();

在这里,我试图获得降级的价值。但它总是得到递增的值。如果我删除“Distinct()”它可以正常工作,但在添加“Distinct()”后会出现此问题。

4

1 回答 1

1

尝试这个:

listOrders.DataSource = (from sp in dbdata.Specifications
                         join ord in dbdata.Orders on sp.O_id equals ord.O_id
                         join prd in dbdata.Products on ord.O_id equals prd.O_ID
                         where sp.Approve == "Yes" && 
                         sp.Awailable_BOM == "Yes" && 
                         prd.Hours_prd == null
                         select sp.O_id).Distinct().OrderByDescending();
于 2012-11-13T04:52:28.297 回答