繁体   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