开发者

Subsonic 3 query like clause

This may be another of those "should be simple" things, but I can't f开发者_开发知识库ind anything on it so here I am asking what will most likely be a stupid question :$

I'm using SubSonic 3 and I want to execute a query with a like clause but can't find that as an option. My straight SQL is like so:

select * from table where column like %value% or column like %anothervalue%

Thanks for any help.

Jon


If you're using Linq you can use StartsWith(), EndsWith(), and Contains()


You can do this with the fluent interface as follows:

List<Product> products = new MyDB().Select
            .From(ProductTable)
            .Where(ProductTable.CategoryColumn).Like("%searchstring%")
            .ExecuteTypedList<Product>();

Or using Contains:

List<Product> products = new MyDB().Select
            .From(ProductTable)
            .Where(ProductTable.CategoryColumn).Contains("searchstring")
            .ExecuteTypedList<Product>();

MyDB is your generated DB name

Or using linq:

List<Product> products = from p in Product.All()
                         where p.Category.Contains("searchstring")
                         select p; 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜