SubSonic Swap Syntax Reference
I am trying to get a subsonic select prompt to work, I am writing a swap method and have tried the following
Select ns = new Select(maincolumns.ToArray());
ns.PageSize = 10; ** Error Here **
ns.PageIndex = 1; ** And Error Here **
ns.Where("IsLive").IsEqualTo(true);
ns.And("Title").Like("%" + SearchTerm + "%");
ns.OrderAsc("RentalExVat");
return ns.ExecuteDataSet().Tables[0];
Now it doesn't recognize ns.PageSize or ns.PageIndex, is the rest of the request working fine? I see that I need to use the new "Query" tool to be able to use these two, but I cannot understand the syntax of the query
any syntax helps to evaluate
0
a source to share
1 answer
SubSonic's query syntax is "free", so your sample code does not apply the Where clause to your query. This snippet might work better:
Select ns = new Select(maincolumns.ToArray());
ns = ns.Where("IsLive").IsEqualTo(true)
.And("Title").Like("%" + SearchTerm + "%")
.OrderAsc("RentalExVat")
.Paged(1, 10); // paging is set here
return ns.ExecuteDataSet().Tables[0];
Also, make sure your "SearchTerm" has been escaped with SQL (or uses an alternate calling pattern), or you are vulnerable to SQL injection.
+4
a source to share