第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

LINQ 查詢連接表的多個(gè) orderby

LINQ 查詢連接表的多個(gè) orderby

C#
qq_笑_17 2021-07-14 16:14:47
我有以下 LinQ 查詢   var CGTABLE = (from cg in DbContext.CGTABLE                              join tcg in DbContext.TCGTABLE on new { cg.CGroupId } equals new { tcg.CGroupId }                                                                                                  where tcg.TId == TId                              select new  {                                  CGroupId = cg.CGroupId,                                  CGroupCode = cg.CGroupCode,                                                                        Description = cg.Description,                                                                        C = cg.C,                                  DisplayOrder = cg.DisplayOrder                              }).ToList();        CGTABLE = CGTABLE.OrderBy(g => g.DisplayOrder).ThenBy(g => g.C.OrderBy(c => c.CCode)).ToList();運(yùn)行良好,但它沒有通過使用 ThenBy 進(jìn)行第二次排序ThenBy(g => g.C.OrderBy(c => c.CCode)我錯(cuò)過了什么?Sample data for better understanding.Data in Tables2  1  2  4  31  4  5  2  13  3  1Should output after both outer and inner list ordered by1  1  2  3  42  1  2  4  53  1  3But Currently it is showing1  4  5  2  12  1  2  4  33  3  1
查看完整描述

1 回答

?
阿波羅的戰(zhàn)車

TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超6個(gè)贊

您不想訂購主列表,我想您正在尋找一種在外部列表中訂購內(nèi)部列表的方法。所以下面的代碼會(huì)為你做:


var CGTABLE = (

    from cg in DbContext.CGTABLE

    join tcg in DbContext.TCGTABLE on new { cg.CGroupId } equals new { tcg.CGroupId }                                                                    

    where tcg.TId == TId

    select new  {

        CGroupId = cg.CGroupId,

        CGroupCode = cg.CGroupCode,                                      

        Description = cg.Description,                                      

        C = cg.C.OrderBy(x => x.CCode),

        DisplayOrder = cg.DisplayOrder

   }).ToList();


   CGTABLE = CGTABLE.OrderBy(g => g.DisplayOrder).ToList();


查看完整回答
反對 回復(fù) 2021-07-31
  • 1 回答
  • 0 關(guān)注
  • 226 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號