System.Linq.Dynamic加入int列表

时间:2017-11-16 07:49:57

标签: c# linq inner-join dynamic-linq

我使用System.Linq.Dynamic.Core创建从类到inetger或字符串列表的内部联接。

现在使用普通的linq语法很容易:

      public class Person
      {
         public int Id { get; set; }
         public String Name { get; set; }
         public String FirstName { get; set; }
         public Int32 Status { get; set; }
      }
// This works
// query is a list of persons..
var idList = new List<int>() {1, 2, 3, 4};
var dynamicQuery = query
                .Join(
                    idList , x => x.Id, y => y, (left, right) => new {left, right});

但是如何在动态linq中做到这一点?我试着没有结果:

var dynamicQuery = query
            .Join(
                idList, "it.Id", "it", "new (outer as card, inner as ids)");

var dynamicQuery = query
            .Join(
                idList, "it.Id", "it => it", "new (outer as card, inner as ids)");

0 个答案:

没有答案