Wiki
Clone wikiWarmCrocConf / Home
Welcome
This is the script I went thru during my talk at WarmCrocConf . The slides and demo must be viewed "in sync" to get the right context.
Demo slides
Slides are available at Slideshare .
The talk was divided in two - one for serverside fun and one for clientside fun.
Serverside
Start fiddler
OData using POCO classes
Show how to create WCF Data Services project in Visual Studio 2010
Explain code, IQueryable, DataServiceKey, Configuration
Set POCO as start page
Launch solution
Show MyAnimals http://localhost:49653/POCO.svc/MyAnimals
Link to entity items http://localhost:49653/POCO.svc/MyAnimals(0)
Inheritance
Explain code, inheritance etc
Set DerivedPOCO as start page
Launch solution
Show MyComplexAnimals http://localhost:49653/DerivedPOCO.svc/MyComplexAnimals
Link to entity items http://localhost:49653/DerivedPOCO.svc/MyComplexAnimals(0)
Show inheritance
Northwind
EntityFramework- show model, SQL Server Northwind
Northwind was downloaded from http://northwinddatabase.codeplex.com/releases/view/71634
Explain entities
Set Northwind as start page
Launch solution
Show Suppliers http://localhost:49653/Northwind.svc/Suppliers
Navigation properties
Show link to /Products http://localhost:49653/Northwind.svc/Suppliers(1)/Products
Supplier has three products
Link to each specific product http://localhost:49653/Northwind.svc/Products(3)
Link to Order_Details http://localhost:49653/Northwind.svc/Products(3)/Order_Details
Link back to Order http://localhost:49653/Northwind.svc/Order_Details(OrderID=10405,ProductID=3)/Order
XML - cursory glance
Misc.
- minor tweaks for configuring SQL Server
Service operations
GET
Show code
http://localhost:49653/Northwind.svc/GetOrdersByCity?city='London'
POST
Change GET to POST and add message request body
DELETE
Get EmployeeTerritory
http://localhost:49653/Northwind.svc/EmployeeTerritories
Get Specific item
Change GET to DELETE in Fiddler (Unnlock session item for editing, edit HTTP request, reissue request)
Puff it's gone :o)
Metadata
http://localhost:49653/Northwind.svc/$metadata
Clientside
Go to demoservice på http://services.odata.org/V3/OData/OData.svc/
SELECT
Full
Products http://services.odata.org/V3/OData/OData.svc/Products
Items as before, with pointers to related items
Also, links to relations
http://services.odata.org/V3/OData/OData.svc/Products(0)/$links/Supplier
Limited
http://services.odata.org/V3/OData/OData.svc/Products(0)?$select ID, Price
filter
http://services.odata.org/V3/OData/OData.svc/Suppliers()?$filter=startswith(Name,'E')
http://services.odata.org/V3/OData/OData.svc/Products()?$filter=ReleaseDate lt datetime'2001-01-01T00:00:00'
http://services.odata.org/V3/OData/OData.svc/Products()?$filter=Price gt 10 -> M
http://services.odata.org/V3/OData/OData.svc/Products()?$filter=Name eq 'Milk'
top
http://services.odata.org/V3/OData/OData.svc/Products/?$top=2
count
http://services.odata.org/V3/OData/OData.svc/Products/$count
OrderBy, Skip,
any, lambda
http://services.odata.org/V3/OData/OData.svc/Categories?$filter=Products/any(p:%20p/Rating%20ge%204)
http://services.odata.org/V3/OData/OData.svc/Categories?$filter=Products/any(p: p/Rating ge 4)
Complex types
http://services.odata.org/V3/OData/OData.svc/Suppliers
- notice Address type
EXPAND
http://localhost:49653/Northwind.svc/Suppliers(1)?$expand=Products
Explain why this links back to original case in slides where client suddenly wanted list of invoices with customer data. Using $expand would give a sort of "JOIN-functionality" and give us teh data we needed - without having the whole stack being enhanced to facilitate the new requirements.
JSON
accept: application/json
Show side by side in Chrome with JSONView extension
Verbose
http://services.odata.org/Experimental/OData/OData.svc/Categories?$format=verbosejson
http://services.odata.org/Experimental/OData/OData.svc/Categories?$format=json
normal
http://services.odata.org/Experimental/OData/OData.svc/Products?$filter=Price%20gt%202.5&$orderby=Price%20desc&$top=2&$format=json
Spatial support
Address in Suppliers
http://services.odata.org/V3/OData/OData.svc/Suppliers()?$filter=geo.distance(Location,%20geography'Point(-122.0354 47.63166)')%20lt%20900
http://services.odata.org/V3/OData/OData.svc/Suppliers()?$filter=geo.distance(Location, geography'Point(-122.0354 47.63166)') lt 900
Linqpad
Explain why it's awesome and when it sucks. "If you know your Linq but not OData". Easy learning curve
OData Query can be seen in "Request Log" tab
Updated