View books-5.json
{
"title": "The Goal: A Process of Ongoing Improvement",
"year": 1992,
"price": 1.45,
"genre": "Business Management",
"stock": 1,
"author": {
"name": "Eliyahu M. Goldratt",
"links": [
{
View books-4.json
{
"title": "The Goal: A Process of Ongoing Improvement",
"year": 1992,
"price": 1.45,
"genre": "Business Management",
"stock": 0,
"author": {
"name": "Eliyahu M. Goldratt",
"links": [
{
View books-3.json
{
"cart": {
"total": 1.45,
"books": [
{
"title": "The Goal: A Process of Ongoing Improvement",
"price": 1.45,
"links": [
{
"rel": "Book",
View books-2.json
{
"title": "The Goal: A Process of Ongoing Improvement",
"year": 1992,
"price": 1.45,
"genre": "Business Management",
"stock": 1,
"author": {
"name": "Eliyahu M. Goldratt",
"links": [
{
View books-1.json
{
"books": [
{
"title": "The Goal: A Process of Ongoing Improvement",
"price": 1.45,
"links": [
{
"rel": "Book",
"href": "/api/books/243"
}
View embedded2.json
{
"href": "/api/books/add",
"method": "post",
"fields": [
{
"type": "text",
"name": "title"
},
{
"type": "resource",
View embedded.json
{
"href": "/api/books/add",
"method": "post",
"fields": [
{
"type": "text",
"name": "title"
},
{
"type": "select",
View webapi.cs
// GET: api/Books/5
[ResponseType(typeof(BookDetailDTO))]
public async Task<IHttpActionResult> GetBook(int id)
{
var book = await db.Books.Include(b => b.Author).Select(b =>
new BookDetailDTO()
{
Id = b.Id,
Title = b.Title,
Year = b.Year,
View http.js
$http({
method: 'GET',
url: '/api/Books/123'
}).then(function successCallback(response) {
// this callback will be called asynchronously
// when the response is available
}, function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
View odata.cs
[EnableQuery]
public IQueryable<Product> Get()
{
return db.Products;
}
[EnableQuery]
public SingleResult<Product> Get([FromODataUri] int key)
{
IQueryable<Product> result = db.Products.Where(p => p.Id == key);