读书人

请问一个模糊查询的有关问题

发布时间: 2012-03-12 12:45:33 作者: rapoo

请教一个模糊查询的问题!
怎么使用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;

读书人网 >.NET

热点推荐