Linq 多条件连接

时间:2023-03-08 17:08:59

var total = (from a in all
                             join g in group_M
                                       on new { MetricPointID = a.MetricPointID, UsageDate = a.UsageDate }
                                       equals new { MetricPointID = g.MetricPointID, UsageDate = g.MaxUsageDate }
                             select new
                             {
                                 MetricPointID = a.MetricPointID,
                                 TotalMonth = a.TotalMonth,
                                 TotalYear = a.TotalYear,
                                 AlertTotalMonth = a.AlertTotalMonth,
                                 AlertTotalYear = a.AlertTotalYear,
                             }).ToList();

 

多条件就使用匿名类