相关疑难解决方法(0)

何时更喜欢用SelectMany()表示的连接超过Linq中用join关键字表示的连接

Linq允许通过使用join关键字或使用带有where关键字的SelectMany()(即几个来自关键字)来表达内部联接:

var personsToState = from person in persons
                     join state in statesOfUS
                     on person.State equals state.USPS
                     select new { person, State = state.Name };
foreach (var item in personsToState)
{
    System.Diagnostics.Debug.WriteLine(item);
}

// The same query can be expressed with the query operator SelectMany(), which is
// expressed as two from clauses and a single where clause connecting the sequences.                     
var personsToState2 = from person in persons
                      from state in statesOfUS
                      where person.State == state.USPS
                      select new { person, State …
Run Code Online (Sandbox Code Playgroud)

linq join

8
推荐指数
1
解决办法
2302
查看次数

标签 统计

join ×1

linq ×1