簡體   English   中英

where 子句在組中不起作用 LINQ c 尖銳

[英]where clause not working in group by LINQ c sharp

我有一個表“register_operation with fields” [Key] int id_registru_casa, DateTime data, int id_cont_sintetic, decimal suma, string tip

tip 只能取 2 個值:“receipts”和“payments”

“Groupby”工作沒有問題,但是當我添加“where”子句不起作用(它沒有顯示任何記錄)(盡管數據庫中有第 19 天、第 9 個月和tip=receipts 的記錄)

        var centralizator_rc = db.register_operation
         .Where(i => (i.data.Day == 19) && (i.data.Month == 9) && (tip=="receipts"))
             .GroupBy(i => i.id_cont_sintetic)
             .Select(g => new {
                 id_cont_sintetic = g.Key,
                 total_receipts = g.Sum(i=>i.suma),
             }).ToList();

謝謝!

已解決:我更改代碼如下:

var centralizator_rc = db.registru_casa  
            .Where(crc=>(crc.data.Month==8) && (crc.data.Day==16) && (crc.tip=="receipts"))
            .GroupBy(crc=> new
            {
                crc.id_cont_sintetic,
                crc.data.Month,
                crc.data.Day,
                crc.tip
            })                             
            .Select(g => new  {
                data = ziuaOK,
                id_cont_sintetic = g.Key.id_cont_sintetic,
                total_incasare = g.Sum(i => i.suma),
                

            }).ToList();

     

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM