小编Men*_*vel的帖子

在IGrouping中使用Where(表达式<Func <T,bool >>)

考虑以下Linq to Entities查询:

return (from lead in db.Leads
    join postcodeEnProvincie in postcodeEnProvincies
    on lead.Postcode equals postcodeEnProvincie.Postcode
    where (lead.CreationDate >= range.StartDate) && (lead.CreationDate <= range.EndDate)
    group lead by postcodeEnProvincie.Provincie into g
    select new Web.Models.GroupedLeads() {
        GroupName = g.Key,
        HotLeads = g.Count(l => l.Type == Data.LeadType.Hot),
        Leads = g.Count(),
        PriorityLeads = g.Count(l => l.Type == Data.LeadType.Priority),
        Sales = g.Count(l => l.Sold),
        ProductA = g.Count(l => l.Producten.Any(a => ((a.Name.Equals("productA", StringComparison.CurrentCultureIgnoreCase)) || (a.Parent.Name.Equals("productA", StringComparison.CurrentCultureIgnoreCase))))),
        ProductB = g.Count(l => l.Producten.Any(a => ((a.Name.Equals("productB", StringComparison.CurrentCultureIgnoreCase)) || (a.Parent.Name.Equals("productB", …
Run Code Online (Sandbox Code Playgroud)

c# linq linq-to-entities

5
推荐指数
1
解决办法
864
查看次数

标签 统计

c# ×1

linq ×1

linq-to-entities ×1