NReco.Data WebApi Example
simple generic REST API to database
Load rows
$.ajax("api/db/rows", { type: "GET", data: { relex : "Products(UnitPrice>20)[*;ProductID desc]" } }).success(function (res) { $('#selectRowsResult').text( JSON.stringify(res) ); });
Run
Load one row
$.ajax("api/db/Products/1", { type: "GET" }).success(function (res) { $('#selectOneRowResult').text( JSON.stringify(res) ); });
Run
Add new row
$.ajax("api/db/Products", { type: "POST", contentType: "application/json", data: JSON.stringify( { ProductID : 100, ProductName : "Test Product" } ) }).success(function (res) { $('#addRowResult').text( JSON.stringify(res) ); });
Run
Update row
$.ajax("api/db/Products/100", { type: "PUT", contentType: "application/json", data: JSON.stringify( { ProductName : "Test Product (updated)" } ) }).success(function (res) { $('#updateRowResult').text( JSON.stringify(res) ); });
Run
Delete row
$.ajax("api/db/Products/100", { type: "DELETE" }).success(function (res) { $('#deleteRowResult').text( JSON.stringify(res) ); });
Run