WCF Data Services查询

上一篇文章http://www.cnblogs.com/2018/archive/2010/10/15/1852579.html介绍了WCF Data Service的基础知识,下面介绍一下查询

查询在WCF Data Services十分的方便,更强的功能在这些类别中可以看到WCF Data Service的超级威力。可以直接在浏览器中输入查询表达式等进行访问

直接使用例子可从http://dskit.codeplex.com下载

查询表达式Query Expressions
一般的查询表达式【返回实体内容】

1. $filter

2. $inlinecount

3. $orderby

4. $skiptoken

5. $skip

6. $top

7. $select

8. $expand

不返回实体内容的查询表达式

· 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).

· $batch path segment - defines the URI that is used to submit requests that contain more than one operation.

· $count path segment - returns the number of entities in the set returned by the URI, without any additional response message metadata.

· $value path 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.

· $metadata path segment - returns metadata, in conceptual schema definition language (CSDL), for the Entity Framework that describes the data model used by the data service.

语法和例子

http://host/<service>/[/<EntitySet>][(<EntityKey>)][/<NavigationProperty>[(<EntityKey>)/...]]] [?$expand] & [?$filter] & [?$orderby] & [?&top] & [?$skip]

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/Customers('ALFKI')?$expand=Orders

http://localhost:1206/WcfDataService.svc/Customers('ALFKI')?$expand=Orders/Order_Details

 

http://localhost:1206/WcfDataService.svc/Customers?$filter=City eq 'london'

以上这些在上面的那个WEB服务启动后都可以直接使用,加上这些表达式就可以完成比较复杂的查询了。

查询表达式中的数据类型

clip_image002

Query Functions例子

http://www.northwindtraders.com/service.svc/Customers?$filter=isof('Ns.SpecialCustomer')

更多的函数和例子参考MSDN

Query Operators例子

· 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'1997-01-01'

更多的约定和例子参考MSDN

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值