在我看来OData就是一个实现Rest full的框架。你可以使用它对server的资源进行操作。那么它能做什么?

1. 获取资源

var context = new DefaultContainer(new Uri("https://services.odata.org/v4/TripPinServiceRW/"));
var people = context.People.Execute();

2.获取特定的资源

var context = new DefaultContainer(new Uri("https://services.odata.org/v4/(S(34wtn2c0hkuk5ekg0pjr513b))/TripPinServiceRW/"));
var person = context.People.ByKey(userName: "russellwhyte").GetValue();

3.查询

var context = new DefaultContainer(new Uri("https://services.odata.org/v4/(S(34wtn2c0hkuk5ekg0pjr513b))/TripPinServiceRW/"));
var people = context.People.Where(c => c.Trips.Any(d => d.Budget > 3000)).Take(2).Select(c => new {c.FirstName, c.LastName});

4.创建资源

var context = new DefaultContainer(new Uri("https://services.odata.org/v4/(S(34wtn2c0hkuk5ekg0pjr513b))/TripPinServiceRW/"));
var lewis = new Person()
{
UserName = "lewisblack",
FirstName = "Lewis",
LastName = "Black",
Emails = new ObservableCollection<string>() {"lewisblack@example.com"},
AddressInfo =
new ObservableCollection<Location>()
{
new Location()
{
Address = "187 Suffolk Ln.",
City = new City() {CountryRegion = "United States", Name = "Boise", Region = "ID"}
}
},
Gender = PersonGender.Male,
Concurrency = 635519729375200400
};
context.AddObject("People", lewis);
context.SaveChanges();

5.关联资源

var context = new DefaultContainer(new Uri("https://services.odata.org/v4/(S(34wtn2c0hkuk5ekg0pjr513b))/TripPinServiceRW/"));
var trip = context.People.ByKey(userName: "russellwhyte").Trips.ByKey(tripId: 0).GetValue();
var dsc = new DataServiceCollection<Person>(context)
{
context.People.ByKey(userName: "lewisblack").GetValue()
};
dsc[0].Trips.Add(trip);</p>
<p>context.SaveChanges();

6.调用函数

In RESTful APIs, there can be some custom operations that contain complicated logic and can be frequently used. For that purpose, OData supports defining functions and actions to represent such operations. They are also resources themselves and can be bound to existing resources.

var context = new DefaultContainer(new
Uri("https://services.odata.org/v4/(S(34wtn2c0hkuk5ekg0pjr513b))/TripPinServiceRW/"));
var trip = context.People.ByKey(userName: "russellwhyte").Trips.ByKey(tripId: 0).GetValue();
var people = trip.GetInvolvedPeople().Execute();

【OData】Odata能做什么?的更多相关文章

  1. OData的初步认识

    What – OData是什么? OData - Open Data Protocal,是一个设计和使用RESTful API的标准.REST本身只是一个构建web服务的思想和理念,其没有规定一个统一 ...

  2. 在ASP.NET Web API中使用OData

    http://www.alixixi.com/program/a/2015063094986.shtml 一.什么是ODataOData是一个开放的数据协议(Open Data Protocol)在A ...

  3. 使用ASP.NET Web API 2创建OData v4 终结点

    开放数据协议(Open Data Protocol[简称OData])是用于Web的数据访问协议.OData提供了一种对数据集进行CRUD操作(Create,Read,Update,Delete)的统 ...

  4. OData – the best way to REST–实例讲解ASP.NET WebAPI OData (V4) Service & Client

    一.概念介绍 1.1,什么是OData? 还是看OData官网的简单说明: An open protocol to allow the creation and consumption of quer ...

  5. WCF Data Service 使用小结 (一)—— 了解OData协议

    最近做了一个小项目,其中用到了 WCF Data Service,之前是叫 ADO.NET Data Service 的.关于WCF Data Service,博客园里的介绍并不多,但它确实是个很好的 ...

  6. WCF Data Service 使用小结 —— 了解OData(一)

    最近做了一个小项目,其中用到了 WCF Data Service,之前是叫 ADO.NET Data Service 的.关于WCF Data Service,博客园里的介绍并不多,但它确实是个很好的 ...

  7. ASP.NET Web API中使用OData

    在ASP.NET Web API中使用OData 一.什么是ODataOData是一个开放的数据协议(Open Data Protocol)在ASP.NET Web API中,对于CRUD(creat ...

  8. 了解OData(一)

    了解OData(一) 最近做了一个小项目,其中用到了 WCF Data Service,之前是叫 ADO.NET Data Service 的.关于WCF Data Service,博客园里的介绍并不 ...

  9. Asp.net core 学习笔记 ( OData )

    2018-12-10 更新 : 从前我都是把 entity 直接用于 odata 曝露 api 给程序用. 如果这个程序是我们自己写的前端,这样的方式非常好,因为就好比前端可以直接对数据库每一个表做操 ...

  10. [转]OData的初步认识 OData v4 Client Code Generator

    本文转自:http://www.cnblogs.com/1zhk/p/5356053.html What – OData是什么? OData - Open Data Protocol,是一个设计和使用 ...

随机推荐

  1. Python 第四阶段 学习记录之----多线程

    多线程 多线程例子, 注释部份即为多线程的使用 #-*- coding: utf-8 -*- # Wind clear raise # 2017/3/5 下午2:34 import socket im ...

  2. 【Oozie学习之一】Oozie

    环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 jdk8 CM5.4 一.简介Oozie由Cloudera公司贡献给A ...

  3. 基于FPGA摄像头图像采集显示系统

    本系统主要由FPGA主控模块.图像采集模块.图像存储模块以及图像显示模块等模块组成.其中图像采集模块选择OV7670摄像头模块,完成对视频图像的采集和解码功能,并以RGB565标准输出RGB 5:6: ...

  4. Linux基础命令---查找用户信息finger

    finger finger指令用来查找.显示指定用户的信息.查询远程主机信息是,可以用user@localhost来指定用户. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.S ...

  5. php ci nginx 伪静态rewrite配置方法

    php ci nginx 伪静态rewrite配置方法 location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$ ...

  6. 一篇关于蓝牙SDP和L2CAP协议的文章

    SDP地址:http://www.cnblogs.com/strive-forever/archive/2011/11/04/2236640.html L2CAP地址:http://www.cnblo ...

  7. 使用github管理Eclipse分布式项目开发

    使用github管理Eclipse分布式项目开发 老关我在前面的博文(github管理iOS分布式项目开发)中介绍了github管理iOS分布式开发,今天老关将向大家介绍使用github管 理Ecli ...

  8. 76 道 Oracle Goldengate 面试问题

    基础 12c新特性 性能 Troubleshoot 其它 1. Oracle Goldengate 支持部署到哪些拓扑? GoldenGate supports the following topol ...

  9. 每日linux命令学习-历史指令查询(history、fc、alias)

    linux历史机制对命令行中输入的命令进行编号并依此保存,以维护命令历史.登录会话期间输入的命令保存在shell内存中,若终止命令则添加至历史文件. 1. 箭头符号方向键 使用键盘上的箭头方向键可以从 ...

  10. 本地MySQL的root所创建用户登录发生[Access denied for user 'root1'@'localhost' (using password: YES)]错误的解决方案

    1.问题描述: 当在SQLyog中执行以下脚本: CREATE DATABASE IF NOT EXISTS sys; USE sys; CREATE USER root1 IDENTIFIED BY ...