匿名类型在此上下文中仅支持基元类型或枚举类型

z4bn682m  于 2021-06-18  发布在  Mysql
关注(0)|答案(0)|浏览(244)

我已经看到有相当多的关于这个错误的参考,所以在这里,但我不能联系解决我的问题。在我的例子中,我尝试合并两个具有相似字段的不同表。下面是控制器操作

public IEnumerable Report(int? year, Guid? gcode)
            {
                DateTime startdate = (new DateTime(DateTime.Now.Year - 1, 7, 1));
                DateTime enddate = (new DateTime(DateTime.Now.Year, 6, 30));

                //get all online payments
                var c = from of in db.OnlinePayments.Include(i => i.Customer).ToList()
                        select new { of.Customer, of.CustomerID, of.PDate, of.Pay, of.POK };
                // get all  offline payments
                var b = from pa in db.OfflinePayments.Include(i => i.Customer).ToList()
                        select new { pa.Customer,  pa.CustomerID, pa.PDate, pa.Pay,pa.POK };
                var all = c.Concat(b);

                var query =
                              (from bk in db.Customers.Where(a=>a.Active)
                               join tr in all.Where(x => x.PDate >= startdate && x.PDate <= enddate && x.POK && x.CustomerID!=2)
                               on bk.CustomerID equals tr.CustomerID into trs

                select new CViewModel
                               {

                                   Name = bk.FirstMiddleLastName,
                                   custguid = bk.CustGuid.GetValueOrDefault(),
                                   TotalPaid = (int?)trs.Sum(e => e.Pay) ?? 0
                               });

                return query.AsEnumerable();
            }

任何帮助都将不胜感激。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题