[2] 2.添加ADO.NET数据服务
[3] 3.NET客启访问DataService
[4] 4.Silverlight客启访问DataService
[5] 5.URL访问
[6] 6.WEB方法
DataService 支持URL方式访问
| 
 格式  | 
 http://[Url]/[ServiceName]/[EntityName]/[NavigationOptions]?[QueryOptions]  | 
| 
 Url: 数据服务所在的网址 ServiceName: 数据服务的名称 EntityName: Entity 名称或是 Service 方法名称 NavigationOptions: 查询 Entity 中关联的设定 QueryOptions: 查询的选项  | 
运算符
| 
 运算符  | 
 说明  | 
| 
 and  | 
|
| 
 or  | 
|
| 
 not  | 
|
| 
 eq  | 
 =  | 
| 
 ne  | 
 !=  | 
| 
 lt  | 
 <  | 
| 
 gt  | 
 >  | 
| 
 le  | 
 <=  | 
| 
 ge  | 
 >=  | 
| 
 add  | 
 +  | 
| 
 sub  | 
 -  | 
| 
 mul  | 
 *  | 
| 
 div  | 
 /  | 
| 
 mod  | 
 余数  | 
| 
 ()  | 
关键字
| 
 expand  | 
 类似于LINQ中的LoadOptions,以此来指定加载此对象相关的通过expand指定的对象。如果需要加载多个对象,用逗号分隔。  | 
| 
 orderby  | 
 指定排序方式。语法为:$orderby=Field [ASC|DESC], [Field[ASC|DESC]]  | 
| 
 Skip Top  | 
 类似于LINQ中的Skip(PageSize * PageIndex).Take(PageSize)用来实现分页。  | 
| 
 Filter  | 
 通过filter这个参数可以在URL里传递过滤条件。  | 
函数
| 
 bool substringof(string p0, string p1)  | 
|
| 
 bool startswith(string p0, string p1)  | 
|
| 
 int indexof(string arg)  | 
|
| 
 string remove(string p0, int pos)  | 
|
| 
 string remove(string p0, string find, string replace)  | 
|
| 
 string substring(string p0, int pos, int length)  | 
|
| 
 string toupper(string p0)  | 
|
| 
 string concat(string p0, string p1)  | 
|
| 
 bool endswith(string p0, string p1)  | 
|
| 
 int length(string p0)  | 
|
| 
 string insert(string p0,int pos, string p1)  | 
|
| 
 string remove(string p0, int pos, int length)  | 
|
| 
 string substring(string p0, int pos)  | 
|
| 
 string tolower(string p0)  | 
|
| 
 string trim(string p0)  | 
|
| 
 int day(DateTime)  | 
|
| 
 int month(DateTime)  | 
|
| 
 int hour(DateTime)  | 
|
| 
 int second(DateTime)  | 
|
| 
 int minute(DateTime)  | 
|
| 
 int year(DateTime)  | 
|
| 
 double round(double)  | 
|
| 
 decimal floor(decimal)  | 
|
| 
 decimal round(decimal)  | 
|
| 
 double ceiling(double)  | 
|
| 
 double floor(double)  | 
|
| 
 decimal ceiling(decimal)  | 
例1:直接访问Entity数据
| 
 http://localhost:1468/myWebDataService.svc/tabA  | 
| 
 
 由于返回的数据是ATOM格式的,如果浏览器支持该格式,会用阅读方式打开,如IE7用RSS阅读器方式打开 以下是返回的数据  | 
| 
 
 
 tabA http://localhost:1468/myWebDataService.svc/tabA 2008-11-17T11:14:32Z 
 
 http://localhost:1468/myWebDataService.svc/tabA('lzm%20%20%20%20%20%20%20') 
 2008-11-17T11:14:32Z 
 
 
 
 
 
 
 lzm 2 5 
 
 
 
 http://localhost:1468/myWebDataService.svc/tabA('wxd%20%20%20%20%20%20%20') 
 2008-11-17T11:14:32Z 
 
 
 
 
 
 
 wxd 1 4 
 
 
 
 http://localhost:1468/myWebDataService.svc/tabA('wxdlzm%20%20%20%20') 
 2008-11-17T11:14:32Z 
 
 
 
 
 
 
 wxdlzm 333 xxx 
 
 
 
 http://localhost:1468/myWebDataService.svc/tabA('wxwinter%20%20') 
 2008-11-17T11:14:32Z 
 
 
 
 
 
 
 wxwinter 3 6 
 
 
 
  | 
例2:使用条件
| 
 http://localhost:1468/myWebDataService.svc/tabA?$filter=a eq 'wxd'  | 
| 
 http://localhost:1468/myWebDataService.svc/tabA?$filter=(a eq 'wxwinter') and (b eq '3')  | 
| 
 
 
 tabA http://localhost:1468/myWebDataService.svc/tabA 2008-11-17T11:26:29Z 
 
 http://localhost:1468/myWebDataService.svc/tabA('wxd%20%20%20%20%20%20%20') 
 2008-11-17T11:26:29Z 
 
 
 
 
 
 
 wxd 1 4 
 
 
 
  | 
例3:排序
| 
 http://localhost:1468/myWebDataService.svc/tabA?$filter=a ne 'wxd' &$orderby=b  | 
| 
 
 
 tabA http://localhost:1468/myWebDataService.svc/tabA 2008-11-17T11:28:10Z 
 
 http://localhost:1468/myWebDataService.svc/tabA('lzm%20%20%20%20%20%20%20') 
 2008-11-17T11:28:10Z 
 
 
 
 
 
 
 lzm 2 5 
 
 
 
 http://localhost:1468/myWebDataService.svc/tabA('wxwinter%20%20') 
 2008-11-17T11:28:10Z 
 
 
 
 
 
 
 wxwinter 3 6 
 
 
 
 http://localhost:1468/myWebDataService.svc/tabA('wxdlzm%20%20%20%20') 
 2008-11-17T11:28:10Z 
 
 
 
 
 
 
 wxdlzm 333 xxx 
 
 
 
  | 
例4:分页
| 
 http://localhost:1468/myWebDataService.svc/tabA?$filter=a ne 'wxd' &$orderby=b &$skip=2&top=2  | 
| 
 
 
 tabA http://localhost:1468/myWebDataService.svc/tabA 2008-11-17T11:30:20Z 
 
 http://localhost:1468/myWebDataService.svc/tabA('wxdlzm%20%20%20%20') 
 2008-11-17T11:30:20Z 
 
 
 
 
 
 
 wxdlzm 333 xxx 
 
 
 
  | 
例5:函数的使用
| 
 http://localhost:1468/myWebDataService.svc/tabA?$filter=a eq trim(' wxd ')  | 
| 
 
 
 tabA http://localhost:1468/myWebDataService.svc/tabA 2008-11-17T12:01:49Z 
 
 http://localhost:1468/myWebDataService.svc/tabA('wxd%20%20%20%20%20%20%20') 
 2008-11-17T12:01:49Z 
 
 
 
 
 
 
 wxd 1 4  | 
                    
                

                
            
        
浙公网安备 33010602011771号