2011-03-28 160 views
0

我正在使用linq查詢來獲取客戶的一張表,其中每個貨幣單位的總金額都存在於我的數據庫中(這一個是確定的。) 當顯示我的結果時查詢與Microsoft報告查看器的結果如表1,但我想要的是表2,只有客戶名稱如「A」和所有單元單元記錄> 0的單元格。將多個單元格放入一個單元格

有什麼方法可以建議?

這是我的代碼產生表1:

var query = from kur in kurToplamlist       
        join cariBilg in db.TBLP1CARIs 
            on kur.CariIdGetSet equals cariBilg.ID 
        select new 
        { 
         cariBilg.ID,//customerid 
         EUROBAKIYE = cariBilg.HESAPADI, 
         cariBilg.K_FIRMAADI,//other column names 
         cariBilg.K_YETKILIADI,//other column names 
         cariBilg.K_FIRMATELEFON,//other column names 
         cariBilg.K_YETKILITELEFON,//other column names 
         AUDBAKIYE = cariBilg.B_CEPTELEFON,//other column names        
         MonetaryUnit = String.Concat(kur.KurToplamMiktarGetSet.ToString(), kur.DovizTuruGetSet.ToString()),//concatenates "100" and "TL/USD etc."       

        }; 

我要的是獲得表2中的圖像 在預先感謝您。

Table image

回答

1
var query = from kur in kurToplamlist 
        where kur.KurToplamMiktarGetSet > 0 
        join cariBilg in db.TBLP1CARIs 
            on kur.CariIdGetSet equals cariBilg.ID 
        select new 
        { 
         cariBilg.ID, 
         EUROBAKIYE = cariBilg.HESAPADI, 
         cariBilg.K_FIRMAADI, 
         cariBilg.K_YETKILIADI, 
         cariBilg.K_FIRMATELEFON, 
         cariBilg.K_YETKILITELEFON, 
         AUDBAKIYE = cariBilg.B_CEPTELEFON, 
         TLBAKIYE = String.Concat(kur.KurToplamMiktarGetSet.ToString(), kur.DovizTuruGetSet.ToString()), 


        }; 
     var dfg = from qre in query 
        select qre.TLBAKIYE; 

     var aq = (from qw in query 
        select new { 
         qw.ID, 
         EUROBAKIYE = qw.EUROBAKIYE, 
         qw.K_FIRMAADI, 
         qw.K_YETKILIADI, 
         qw.K_FIRMATELEFON, 
         qw.K_YETKILITELEFON, 
         AUDBAKIYE = qw.AUDBAKIYE, 
         TLBAKIYE = String.Join(",", (from qre in query 
                where qre.ID == qw.ID 
                select qre.TLBAKIYE).Distinct()) 

       }).Distinct();    

     return aq;   

這就是我的回答。

相關問題