NRepository: OData & WebApi examples

*** Preliminary examples V0.7 ***

Sample code built on the Northwind database created using CodeFirst (see Northwind.Domain.Core project).
To view database goto SqlServer Management Studio and connect using the server name '(LocalDb)\v11.0'. The database will be named NRepository_Northwind.

N.B. This sample code is still currently being developed. Why not recheck in a couple of days for a newer version :)

Using projection via query interception

/api/orders/ImportantCustomers
/api/orders/AllCustomers
/api/orders/AllCustomers?take=10&orderby=CombinedOrderValue
/api/orders/AllCustomers?take=2&skip=1&orderby=CombinedOrderValue&ascending=false

Retrieving data via Stored procedure using query strategy

/api/Orders/CustomerOrderHistory/VINET


Using projection via query interception calling the database using sql

/api/Sales/SalesCategories

Insert / Update Category with auditing and auto property setting

Id
Category Name:
Category Description:



Simple Search, Paging & Ordering Strategies Example

/api/accounts/SearchAccounts
/api/Accounts/SearchAccounts?search=j&ascending=false
/api/Accounts/SearchAccounts?page=2&pagesize=3



Standard OData controller using Customer Specific specification strategy

/odata/Customers
/odata/Customers?customerId='ANTON



Uses MongoDb storage instead of SqlServer if the following steps are followed.

In order to use the mongo database implementation of this OdataController please ensure that you have :
1. Installed MongoDb and that the MongoD.exe is running.
2. You've uncommented the highlighted lines in the UnityConfig.

If you are unsure about which implemention of IRepository is being used (EntityFrameworkRepository or MongoDbRepository) simply place a breakpoint in the CustomerController constructor and check it's type.

/odata/Customers
/odata/Customers?customerId='ANTON



A read only controller that uses projection to abstract the domain entities and stops the bleeding of domain entities into your OData implementation

odata/readonly/AggregateCustomerSales
/odata/Customers?customerId='ANTON