Adi*_*.el 0 c# linq sdf visual-studio-2010
我在C#中使用LINQ搜索.我的一个搜索需要将a转换string为int.当我尝试使用int.parse()或时convert.toInt32(),它显示错误(在LINQ中无法识别)
例如:
var google = from p in ctx.dates
where int.Parse(p.effDate) < 20101212 && int.Parse(p.effDate) > 20121212
select p;
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我有一个字符串,其中包含我的日期yyyymmdd格式,我想将其转换为整数,以便我可以在这些日期之间进行搜索.
该yyyyMMdd格式有一个很好的特性,即按字典顺序是一样的时间顺序排列,以便您可以使用字符串比较:
var google = from p in ctx.dates
where p.effDate.CompareTo("20121212") < 0
&& p.effDate.CompareTo("20101212") > 0
select p;
Run Code Online (Sandbox Code Playgroud)