日期:2014-05-20  浏览次数:20916 次

请教一个模糊查询的问题!
怎么使用LINQ 后端匹配查询,如SQL中的 like '32%'

------解决方案--------------------
%表示零长度或任意长度的字符串;_表示一个字符串;[]表示在某范围区间的一个字符;
[^]表示不再某范围区间的一个字符。
你的LINQ的写法是
var q = from c in db.Customers
where SqlMethods.Like(c.CustomerID,"32%")
select c;
------解决方案--------------------
C# code
var query = from c in LQDC.Customers

      where SqlMethods.Like(c.City, "32%")

select c;

------解决方案--------------------
探讨
怎么使用LINQ 后端匹配查询,如SQL中的 like '32%'

------解决方案--------------------
C# code
where c.CustomerID.EndWith("32") //like '32%'
where c.CustomerID.StartWith("32") //like '%32'
where c.CustomerID.Contains("32") //like '%32%'

------解决方案--------------------
探讨
C# code

where c.CustomerID.EndWith("32") //like '32%'
where c.CustomerID.StartWith("32") //like '%32'
where c.CustomerID.Contains("32") //like '%32%'

------解决方案--------------------
探讨

小弟在这谢谢大家

------解决方案--------------------
探讨
C# code

var query = from c in LQDC.Customers

where SqlMethods.Like(c.City, "32%")

select c;