开发者

Dynamic Linq - String.Split

开发者 https://www.devze.com 2023-01-24 05:43 出处:网络
It appears that Dynamic Linq doesn\'t implement the String.Split method. Is there a way ac开发者_Go百科hieve the same results with Dynamic Linq ?Dynamic Linq does support String.Split and also callin

It appears that Dynamic Linq doesn't implement the String.Split method.

Is there a way ac开发者_Go百科hieve the same results with Dynamic Linq ?


Dynamic Linq does support String.Split and also calling other .net type methods as shown below

var query =
                db.Customers.Where("City.Split(\"abc\".ToCharArray()).Length == 1 and Orders.Count >= @1", "London", 10).
                OrderBy("CompanyName").
                Select("New(CompanyName as Name, Phone)");

It was able to convert the string to expression tree but as SQL doesn't have any string split operation it throws error if you run it on SQL


Answer to comment below:

string teststring = "one, two, three";

var x = from string z in (teststring.Split(',').AsEnumerable())
where z.Trim() == "two"
select z;

What exactly do you want to do? The following works just fine in LINQPad

from z in ("4,3,5,2,1".Split(',').AsEnumerable())
  select z

0

精彩评论

暂无评论...
验证码 换一张
取 消