PreviousArticleHttp://www.cnblogs.com/2018/archive/2010/10/15/1852579.htmlintroduces the basic knowledge of WCF data service. The following describes how to query
Query is very convenient in WCF data services, and more powerful features can be seen in these categories as the super power of WCF data service. You can directly enter a query expression in your browser for access.
Direct use example can be downloaded from http://dskit.codeplex.com
Query expressions a general query expression [returns object content]
1.$ Filter
2.$ Inlinecount
3.$ Orderby
4.$ Skiptoken
5.$ Skip
6.$ Top
7.$ Select
8.$ Expand
Returns no query expression for the object content.
· Service root path-returns information about the entity sets that can be accessed on the data service.
· Service operation-defines a method that is exposed as an endpoint on the data service. For more information, see service operations (WCF data services ).
·$ BatchPath segment-defines the URI that is used to submit requests that contain more than one operation.
·$ CountPath segment-returns the number of entities in the Set returned by the URI, without any additional response message metadata.
·$ ValuePath segment-returns the value of a property that is a primitive type, without any additional response message metadata. Also used to access binary data from a media resource.
·$ MetadataPath segment-returns metadata, in Conceptual schema definition language (CSDL), for the entity framework that describes the data model used by the data service.
Syntax and example
http: // host/ /[/ ] [( )] [/ [( ) /...] [? $ Expand] & [? $ Filter] & [? $ Orderby] & [? & Top] & [? $ Skip]
http: // localhost: 1206/wcfdataservice. svc/customers? $ Orderby = city DESC |
& Lt; TD width = "568" valign = "TOP" & gt; & lt;/TD & gt;
http: // localhost: 1206/wcfdataservice. svc/customers? $ Orderby = city DESC & $ skip = 10 |
http: // localhost: 1206/wcfdataservice. svc/customers? $ Skip = 30 & $ Top = 10 |
& Lt; TD width = "568" valign = "TOP" & gt; & lt;/TD & gt;
http: // localhost: 1206/wcfdataservice. svc/Mers MERs ('alfki ')? $ Expand = orders |
http: // localhost: 1206/wcfdataservice. svc/Mers MERs ('alfki ')? $ Expand = orders/order_details |
& Lt; TD width = "568" valign = "TOP" & gt; & lt;/TD & gt;
http: // localhost: 1206/wcfdataservice. svc/customers? $ Filter = city EQ 'London ' |
The above web service can be directly used after it is started. With these expressions, you can complete complicated queries.
Data Type in the query expression
Query functions example
Http://www.northwindtraders.com/service.svc/Customers? $ Filter = isof ('ns. specialcustomer ')
For more functions and examples, refer to msdn
Query operators example
· Grouping operators :()
· Logical operators: And or not EQ ne lt gt le Ge
· Arithmetic Operators: Add sub Mul Div mod
Http: // localhost: 1206/wcfdataservice. svc/orders? $ Filter = orderdate GT datetime '2017-01-01'
For more conventions and examples, refer to msdn