How to convert this foreach loop into Linq code?

前端 未结 4 571
醉酒成梦
醉酒成梦 2021-01-03 11:21

I am new one with Linq and I would like to modify my old c# code to use Linq. The idea of this code to select all tables where it\'s not set and reference’s field PrimaryTab

4条回答
  •  不知归路
    2021-01-03 11:44

    tables.AddRange(dbServer.Tables
        .Where(t => !t.IsSet)
        .SelectMany(t => table.References)
            .Where(r => r.PrimaryTable == "myTable"));
    

提交回复
热议问题