C# LINQ to Entities does not recognize the method 'Boolean'

后端 未结 2 1444
悲哀的现实
悲哀的现实 2021-01-05 11:52

I have the following linq expression in lambda syntax:

var myValue = 6;
var from = 2;
var to = 8;

var res = MyList.Where(m => m.person.Id == person.Id
           


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-05 12:42

    In Addition to this, if you want to pass the values to IsBetween method from MyList.

    Take a wrapper class (here Person) contains the same properties to be passed to the method. and do something like this:

    var res = MyList.Where(m => m.person.Id == person.Id)
                .Select(x => new Person { p1 = x.p1, p2 = x.p2 })
                .AsEnumerable()
                .where(x => (IsBetween(x.p1, x.p2)))
                .ToList());
    

提交回复
热议问题