Way*_*man 1 c# linq subsonic subsonic3
Subsonic 3.0的新手,想知道如何在对象属性上执行LIKE运算符.鉴于以下类,我将如何使用Subsonic 3.0执行LIKE操作.例如SELECT*FROM categories WHERE name LIKE'%foo%';
public class Category
{
private String categoryID;
private String name;
public Category()
{
// Do Nothing
}
public Category(String name)
{
this.Name = name;
}
public string CategoryID
{
get { return this.categoryID; }
set { this.categoryID = value; }
}
public string Name
{
get { return this.name; }
set { this.name = value; }
}
Run Code Online (Sandbox Code Playgroud)
}
小智 9
更好的方法是:
return new SubSonic.Select().From(Categories.Schema)
.Where(Categories.name).Contains("foo")
.ExecuteTypedList<Categories>();
Run Code Online (Sandbox Code Playgroud)
这将使用特定于提供程序的通配符.您还可以使用StartsWith和EndWith.