WCF Data Services Query

Source: Internet
Author: User

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]

& Lt; TD width = "568" valign = "TOP" & gt; & lt;/TD & gt; & Lt; TD width = "568" valign = "TOP" & gt; & lt;/TD & gt; & Lt; TD width = "568" valign = "TOP" & gt; & lt;/TD & gt;

http: // localhost: 1206/wcfdataservice. svc/customers? $ Orderby = city DESC

http: // localhost: 1206/wcfdataservice. svc/customers? $ Orderby = city DESC & $ skip = 10

http: // localhost: 1206/wcfdataservice. svc/customers? $ Skip = 30 & $ Top = 10

http: // localhost: 1206/wcfdataservice. svc/Mers MERs ('alfki ')? $ Expand = orders

http: // localhost: 1206/wcfdataservice. svc/Mers MERs ('alfki ')? $ Expand = orders/order_details

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.