代码之家  ›  专栏  ›  技术社区  ›  Rony

Linq:交叉联接的表达式树语法是什么?

  •  1
  • Rony  · 技术社区  · 15 年前

    如何用表达式树语法编写此Linq查询

    from x in 100.To(999)
    from y in 100.To(999)
    let product = x * y
    where product.IsEven()
    select product
    
    1 回复  |  直到 15 年前
        1
  •  1
  •   diceguyd30    15 年前

    相当于“from x from y select”的是“selectmany”关键字,与附加的“select”一起使用:

    100.To(999).SelectMany(x => 100.To(999).Select(y => x * y))
    .Where(x => x.IsEven())