28
ASP.NET + jQuery + Odata = Goodness Stephen Walther Superexpert.com Stephen.Walther@Superexpert .com

ASP.NET + jQuery + Odata = Goodness

  • Upload
    horace

  • View
    43

  • Download
    0

Embed Size (px)

DESCRIPTION

ASP.NET + jQuery + Odata = Goodness. Stephen Walther Superexpert.com [email protected]. Agenda. Overview of OData /WCF Data Services Querying OData from jQuery Creating/Editing OData from jQuery Client/Server Validation Useful OData plugins. - PowerPoint PPT Presentation

Citation preview

Page 1: ASP.NET +  jQuery  +  Odata  = Goodness

ASP.NET + jQuery + Odata = Goodness

Stephen WaltherSuperexpert.com

[email protected]

Page 2: ASP.NET +  jQuery  +  Odata  = Goodness

Agenda

• Overview of OData/WCF Data Services• Querying OData from jQuery• Creating/Editing OData from jQuery• Client/Server Validation• Useful OData plugins

Page 3: ASP.NET +  jQuery  +  Odata  = Goodness

The Open Data Protocol (OData)

Defined at Odata.org:

● Open Standard● REST = Representational State Transfer● Supports XML (Atom) and JSON ● XHR and JSONP

Page 4: ASP.NET +  jQuery  +  Odata  = Goodness

OData Data Sources

• Netflix• NuGet• Stack Overflow• SQL Azure• Azure Table Storage• SharePoint 2010• Windows Live

• SQL Server Reporting Services

• eBay

Page 5: ASP.NET +  jQuery  +  Odata  = Goodness

WCF Data Services

• Exposes data using the OData protocol

• WCF Data Services February 2011 CTP2● Works with Entity Framework 4.1 (Code First)

Page 6: ASP.NET +  jQuery  +  Odata  = Goodness

WCF Data Services

Exposes DBContext:

Page 7: ASP.NET +  jQuery  +  Odata  = Goodness

Querying OData

OData URIs have three parts:● Service Root● Resource Path● Query Options

Page 8: ASP.NET +  jQuery  +  Odata  = Goodness

Querying OData

Query Options:● $select● $filter● $top● $skip● $orderby● $inlinecount● $count

• $expand• $format• $links• $metadata• $value

Page 9: ASP.NET +  jQuery  +  Odata  = Goodness

Query OData (Operators)

Page 10: ASP.NET +  jQuery  +  Odata  = Goodness

Query OData (String Filters)

Page 11: ASP.NET +  jQuery  +  Odata  = Goodness

Query OData (Date Filters)

Page 12: ASP.NET +  jQuery  +  Odata  = Goodness

Query OData (Math Filters)

Page 13: ASP.NET +  jQuery  +  Odata  = Goodness

Query OData (Type Filters)

Page 14: ASP.NET +  jQuery  +  Odata  = Goodness

Query OData

__metadata:

Page 15: ASP.NET +  jQuery  +  Odata  = Goodness

Query OData with jQuery

Page 16: ASP.NET +  jQuery  +  Odata  = Goodness

Create New Entities

Page 17: ASP.NET +  jQuery  +  Odata  = Goodness

Edit Existing Entities

Page 18: ASP.NET +  jQuery  +  Odata  = Goodness

Validation

Client = Use jQuery ValidateUse for immediate user feedback

Server = Use Entity FrameworkUse for domain validation

Page 19: ASP.NET +  jQuery  +  Odata  = Goodness

Client ValidationUse jQuery Validate to create client validation rules

Page 20: ASP.NET +  jQuery  +  Odata  = Goodness

Server ValidationUse Data Annotation validators to validate properties:

Page 21: ASP.NET +  jQuery  +  Odata  = Goodness

Server ValidationUse the IValidatableObject interface for more complex validation:

Page 22: ASP.NET +  jQuery  +  Odata  = Goodness

Server ValidationHandle the Entity Framework DbEntityValidationException in your service class:

Page 23: ASP.NET +  jQuery  +  Odata  = Goodness

jQuery OData Plugin

• Created by Egil Hansen: ● https://github.com/egil/jquery.odata

• Updated fork at:● https://github.com/StephenWalther/jquery.odata

Page 24: ASP.NET +  jQuery  +  Odata  = Goodness

DataJS Plugin

• Created by Microsoft:● http://datajs.codeplex.com/

• Supports reading and updating data

• Supports HTML5 DOM Storage

Page 25: ASP.NET +  jQuery  +  Odata  = Goodness

Resources

● WCF Data Services March 2011 CTP2• http://

www.microsoft.com/downloads/en/details.aspx?FamilyID=60fb0117-8cea-4359-b392-6b04cdc821be

● Entity Framework 4.1 (Included with MVC3)• http://www.microsoft.com/downloads/en/details.aspx?FamilyID=2dc5ddac-5a96-48b

2-878d-b9f49d87569a● jQuery Templates

• Install-Package jQuery.Templates● jQuery UI (Included with MVC3)

• Install-Package jQuery.UI● jQuery Odata

• https://github.com/egil/jquery.odata/wiki• https://github.com/StephenWalther/jquery.odata

● DataJS• http://datajs.codeplex.com/

Page 26: ASP.NET +  jQuery  +  Odata  = Goodness

Download the Sample Code

Visit Stephen Walther’s blog to download the sample code for this talk:

● http://StephenWalther.com

Page 27: ASP.NET +  jQuery  +  Odata  = Goodness

Website: http://Superexpert.com Email: [email protected]: 800 691 - 7140

Page 28: ASP.NET +  jQuery  +  Odata  = Goodness

Your Feedback is Important

Please fill out a session evaluation form.

Thank you!