SlideShare uma empresa Scribd logo
1 de 39
#devsum15
Learning How to Shape and
Configure an OData Feed for High
Performing Web Sites and
Applications
Chris Woodruff
@cwoodruff cwoodruff@live.com
Hi, I’m Woody!
Chris Woodruff
• cwoodruff@live.com
• http://chriswoodruff.com
• http://deepfriedbytes.com
• twitter @cwoodruff
VALIDATION CLIENT SIDEBEST PRACTICES
AGENDA
What are the 2 Sides of OData?
SERVER-SIDE (PRODUCER) CLIENT-SIDE (CONSUMER)
Server Side for OData
UNDERSTAND REST
The Top Reasons You Need to Learn about Data in Your Windows Phone App
WHAT IS REST?
RESOURCES
VERBS
URL
WHAT SHOULD YOU KNOW ABOUT REST?
Resources
REST uses addressable resources to define the
structure of the API. These are the URLs you use to
get to pages on the web
Request Headers
These are additional instructions that are sent with the
request. These might define what type of response is
required or authorization details.
Request Verbs
These describe what you want to do with the resource.
A browser typically issues a GET verb to instruct the
endpoint it wants to get data, however there are many
other verbs available including things like POST, PUT
and DELETE.
Request Body
Data that is sent with the request. For example a
POST (creation of a new item) will required some data
which is typically sent as the request body in the format
of JSON or XML.
Response Body
This is the main body of the response. If the request
was to a web server, this might be a full HTML page, if
it was to an API, this might be a JSON or XML
document.
Response Status codes
These codes are issues with the response and give
the client details on the status of the request.
REST & HTTP VERBS
GET
Requests a representation of the specified
Requests using GET should only retrieve
have no other effect.
POST
Requests that the server accept the entity
enclosed in the request as a new
subordinate of the web resource identified
by the URI.
PUT
Requests that the enclosed entity be stored
under the supplied URI.
DELETE
Deletes the specified resource.
EXAMPLES OF REST AND ODATA
/Products
RESOURCE EXPECTED OUTCOMEVERB RESPONSE CODE
/Products?$filter=Color eq ‘Red'
/Products
/Products(81)
/Products(881)
/Products(81)
/Products(81)
GET
GET
POST
GET
GET
PUT
DELETE
A list of all products in the system
A list of all products in the system
where the color is red
Creation of a new product
Product with an ID of 81
Some error message
Update of the product with ID of 81
Deletion of the product with ID of
81
200/OK
200/OK
201/Created
200/OK
404/Not Found
204/No Content
204/No Content
BEST PRACTICES
Get to know the OData Protocol!!!
Examples (http://chinookdata.azurewebsites.net)
GET serviceRoot/Artists?$filter=Name eq 'Foo Fighters'
GET serviceRoot/Artists?$filter=contains(Name, 'Foo')
GET serviceRoot/Artists(1)?$expand=Albums
GET serviceRoot/Artists(58)/Albums?$orderby=Title desc
GET serviceRoot/Artists?$skip=20&$top=10
GET serviceRoot/Artists?$search=AC ***
GET serviceRoot/Customer?$filter=Email/any(s:endswith(s, 'contoso.com')) ***
GET serviceRoot/$metadata
Query Projection
Examples (http://chinookdata.azurewebsites.net)
PROPERTIES OF THE CUSTOMER ENTITY
• CustomerId
• FirstName
• LastName
• Company
• Address
• City
• State
QUERY PROJECTIONS FOR PERFORMANCE
GET serviceRoot/Customers?$select=
FirstName, LastName, Company
GET serviceRoot/Customers?$select=
LastName, Address, City, State, Country,
PostalCode
GET serviceRoot/Customers?$select=
FirstName, LastName, Phone, Email
• Country
• PostalCode
• Phone
• Fax
• Email
• SupportRepId
Server Side Paging
Examples
[EnableQuery(PageSize=20)]
Configuration Settings
Examples
invoice.Ignore(t => t.InvoiceDate);
Data Caching with Web API OData v4
Example
Add the CacheCow Server NuGet package to your server project.
Example
Add the following to your WebApiConfig.cs file:
var cacheCowCacheHandler = new CachingHandler(config);
config.MessageHandlers.Add(cacheCowCacheHandler);
When you get a resource you will get an Etag
ETag: W/”002a41972c3d43f0bb14d033907b3f41″
When you make a second request to the same resource, you should send this ETag. The
server uses this identifier to check if the resource you requested has changed
(remember, the server is the authoritative source). If the resource has indeed changed,
it sends you the latest copy. Otherwise, it sends a 304 Not Modified.
VALIDATION AND FILTERING
QUERYABLE ODATAATTRIBUTES
AllowedFunctions
Consider disabling the any() and all() functions, as these can be
0
5
IgnoreDataMember (not with
Queryable)
Represents an Attribute that can be placed on a property to specify
that the property cannot be navigated in OData query.
0
6
PageSize
Enable server-driven paging, to avoid returning a large data set in
one query. For more information
0
1
AllowedQueryOptions
Do you need $filter and $orderby? Some applications might allow
client paging, using $top and $skip, but disable the other query
options.
0
2
AllowedOrderByProperties
Consider restricting $orderby to properties in a clustered index.
Sorting large data without a clustered index is slow.
0
3
AllowedLogicalOperators
Consider any logical operators that you do not want to allow
0
4
Examples
[EnableQuery(AllowedQueryOptions = AllowedQueryOptions.Filter)]
[EnableQuery(AllowedLogicalOperators = AllowedLogicalOperators.Equal)]
[EnableQuery(AllowedFunctions = AllowedFunctions.AllStringFunctions)]
[EnableQuery(AllowedOrderByProperties = "ID")]
ODATAATTRIBUTES (CONT)
NotExpandable
Represents an Attribute that can be placed on a property to specify
be used in the $expand OData query option.
0
5
NotNavigable
Represents an Attribute that can be placed on a property to specify
that the property cannot be navigated in OData query.
0
6
NotSortable
Represents an attribute that can be placed on a property to specify
that the property cannot be used in the $orderby OData query
option.
0
7
NonFilterable
Represents an Attribute that can be placed on a property to specify
that the property cannot be used in the $filter OData query option.
0
1
UnSortable
Represents an Attribute that can be placed on a property to specify
that the property cannot be used in the $orderby OData query
option.
0
2
NotExpandable
Represents an Attribute that can be placed on a property to specify
that the property cannot be used in the $expand OData query
option.
0
3
NotCountable
Represents an Attribute that can be placed on a property to specify
that the $count cannot be applied on the property.
0
4
[NonFilterable]
[Unsortable]
public string Name { get; set; }
QUERY SECURITY
Consider disabling the any() and all() functions,
as these can be slow.
0
6
If any string properties contain large strings—
for example, a product description or a blog
entry—consider disabling the string functions.
0
7
Consider disallowing filtering on navigation
properties. Filtering on navigation properties
can result in a join, which might be slow,
depending on your database schema.
0
8
Test your service with various queries and
profile the DB.
0
1
Enable server-driven paging, to avoid returning
a large data set in one query.
0
2
Do you need $filter and $orderby? Some
applications might allow client paging, using
$top and $skip, but disable the other query
options.
0
3
Consider restricting $orderby to properties in a
clustered index. Sorting large data without a
clustered index is slow.
0
4
Consider restricting $filter queries by writing a
validator that is customized for your database.
0
9
Maximum node count: The MaxNodeCount
property on [Queryable] sets the maximum
number nodes allowed in the $filter syntax tree.
The default value is 100, but you may want to
set a lower value, because a large number of
nodes can be slow to compile.
0
5
VALIDATION PATHS
Filter Query
Represents a validator used to validate a
FilterQueryOption based on the
ODataValidationSettings.
Order By Query
Represents a validator used to validate an
OrderByQueryOption based on the
ODataValidationSettings.
OData Query
Represents a validator used to validate OData queries
based on the ODataValidationSettings.
Select Expand Query
Represents a validator used to validate a
SelectExpandQueryOption based on the
ODataValidationSettings.
Skip Query
Represents a validator used to validate a
SkipQueryOption based on the
ODataValidationSettings.
Top Query
Represents a validator used to validate a
TopQueryOption based on the
ODataValidationSettings.
QUERY SECURITY
// Validator to prevent filtering on navigation properties.
public class MyFilterQueryValidator : FilterQueryValidator
{
public override void ValidateNavigationPropertyNode(
Microsoft.Data.OData.Query.SemanticAst.QueryNode sourceNode,
Microsoft.Data.Edm.IEdmNavigationProperty navigationProperty,
ODataValidationSettings settings)
{
throw new ODataException("No navigation properties");
}
}
// Validator to restrict which properties can be used in $filter expressions.
public class MyFilterQueryValidator : FilterQueryValidator
{
static readonly string[] allowedProperties = { "ReleaseYear", "Title" };
public override void ValidateSingleValuePropertyAccessNode(
SingleValuePropertyAccessNode propertyAccessNode,
ODataValidationSettings settings)
{
string propertyName = null;
if (propertyAccessNode != null)
{
propertyName = propertyAccessNode.Property.Name;
}
if (propertyName != null && !allowedProperties.Contains(propertyName))
{
throw new ODataException(
String.Format("Filter on {0} not allowed", propertyName));
}
base.ValidateSingleValuePropertyAccessNode(propertyAccessNode,
settings);
}
}
Demo
www.chriswoodruff.com Page Number 31
Client Side for OData
DEBUGGING/TESTING
XODATA
Web-based OData Visualizer
FIDDLER
Free web debugging tool which
logs all HTTP(S) traffic between
your computer and the
Internet.
LINQPAD (v3)
Interactively query SQL
databases (among other data
sources such as OData or WCF
Data Services) using LINQ, as
well as interactively writing C#
code without the need for an
IDE.
ODATA
VALIDATOR
Enable OData service authors
to validate their
implementation against the
OData specification to ensure
the service interoperates well
with any OData client.
TESTING/DEBUGGING ODATA
www.websitename.com
CONSUMING ODATA
Demo
Show How to Consume an OData Feed in an Universal App
GITHUB
http://github.com/cwoodruff
Project:
ChinookWebAPIOData
ChinookOData
Where can you find the source for this talk?
ODATA WORKSHOP
01
02
03
04
TESTING/DEBUGGING ODATA
DEVELPING CLIENT SIDE SOLUTIONS
• Web Apps using Javascript to consume Odata
• iOS Swift development for native iPhone and iPad
apps
• Windows 8.1 and Windows Phone apps C# and WinJS
• Android development using Java
• Using Xamarin for consuming OData
LEARNING THE PROTOCOL
• The Metadata and Service Model of OData
• URI Conventions of OData
• Format Conventions of OData
• OData HTTP Conventions and Operations
DEVELPING SERVER SIDE SOLUTIONS
• ASP.NET Web API
• Advanced Performance Tips and Best Practices
Go to http://ChrisWoodruff.com for more details and
pricing
THANK YOU
Find me around the conference and would enjoy chatting
Email: cwoodruff@live.com
Twitter: @cwoodruff

Mais conteúdo relacionado

Mais procurados

JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and ODataAnil Allewar
 
OData Introduction and Impact on API Design (Webcast)
OData Introduction and Impact on API Design (Webcast)OData Introduction and Impact on API Design (Webcast)
OData Introduction and Impact on API Design (Webcast)Apigee | Google Cloud
 
Gaining the Knowledge of the Open Data Protocol (OData)
Gaining the Knowledge of the Open Data Protocol (OData)Gaining the Knowledge of the Open Data Protocol (OData)
Gaining the Knowledge of the Open Data Protocol (OData)Woodruff Solutions LLC
 
Learning To Run - XPages for Lotus Notes Client Developers
Learning To Run - XPages for Lotus Notes Client DevelopersLearning To Run - XPages for Lotus Notes Client Developers
Learning To Run - XPages for Lotus Notes Client DevelopersKathy Brown
 
OData: A Standard API for Data Access
OData: A Standard API for Data AccessOData: A Standard API for Data Access
OData: A Standard API for Data AccessPat Patterson
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & DevelopmentAshok Pundit
 
RESTful API Design Fundamentals
RESTful API Design FundamentalsRESTful API Design Fundamentals
RESTful API Design FundamentalsHüseyin BABAL
 
OData for iOS developers
OData for iOS developersOData for iOS developers
OData for iOS developersGlen Gordon
 
Open Data Protocol (OData)
Open Data Protocol (OData)Open Data Protocol (OData)
Open Data Protocol (OData)Pistoia Alliance
 
Http Status Code Errors in SEO
Http Status Code Errors in SEOHttp Status Code Errors in SEO
Http Status Code Errors in SEOAdela Roger
 
Design Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsDesign Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsStormpath
 
Salesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command lineSalesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command lineCyrille Coeurjoly
 
The never-ending REST API design debate -- Devoxx France 2016
The never-ending REST API design debate -- Devoxx France 2016The never-ending REST API design debate -- Devoxx France 2016
The never-ending REST API design debate -- Devoxx France 2016Restlet
 

Mais procurados (19)

Odata
OdataOdata
Odata
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and OData
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
 
OData Introduction and Impact on API Design (Webcast)
OData Introduction and Impact on API Design (Webcast)OData Introduction and Impact on API Design (Webcast)
OData Introduction and Impact on API Design (Webcast)
 
Gaining the Knowledge of the Open Data Protocol (OData)
Gaining the Knowledge of the Open Data Protocol (OData)Gaining the Knowledge of the Open Data Protocol (OData)
Gaining the Knowledge of the Open Data Protocol (OData)
 
Learning To Run - XPages for Lotus Notes Client Developers
Learning To Run - XPages for Lotus Notes Client DevelopersLearning To Run - XPages for Lotus Notes Client Developers
Learning To Run - XPages for Lotus Notes Client Developers
 
OData: A Standard API for Data Access
OData: A Standard API for Data AccessOData: A Standard API for Data Access
OData: A Standard API for Data Access
 
OData Services
OData ServicesOData Services
OData Services
 
Doing REST Right
Doing REST RightDoing REST Right
Doing REST Right
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
Practical OData
Practical ODataPractical OData
Practical OData
 
RESTful API Design Fundamentals
RESTful API Design FundamentalsRESTful API Design Fundamentals
RESTful API Design Fundamentals
 
OData for iOS developers
OData for iOS developersOData for iOS developers
OData for iOS developers
 
Open Data Protocol (OData)
Open Data Protocol (OData)Open Data Protocol (OData)
Open Data Protocol (OData)
 
Http Status Code Errors in SEO
Http Status Code Errors in SEOHttp Status Code Errors in SEO
Http Status Code Errors in SEO
 
Design Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsDesign Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIs
 
Salesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command lineSalesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command line
 
The never-ending REST API design debate -- Devoxx France 2016
The never-ending REST API design debate -- Devoxx France 2016The never-ending REST API design debate -- Devoxx France 2016
The never-ending REST API design debate -- Devoxx France 2016
 

Semelhante a Learning How to Shape and Configure an OData Service for High Performing Web and Mobile Applications

Wcf data services
Wcf data servicesWcf data services
Wcf data servicesEyal Vardi
 
Gaining the Knowledge of the Open Data Protocol (OData)
Gaining the Knowledge of the Open Data Protocol (OData)Gaining the Knowledge of the Open Data Protocol (OData)
Gaining the Knowledge of the Open Data Protocol (OData)Woodruff Solutions LLC
 
Learning How to Shape and Configure an OData Feed for High Performing Web Sit...
Learning How to Shape and Configure an OData Feed for High Performing Web Sit...Learning How to Shape and Configure an OData Feed for High Performing Web Sit...
Learning How to Shape and Configure an OData Feed for High Performing Web Sit...Woodruff Solutions LLC
 
JAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJerry Kurian
 
Android App Development 06 : Network & Web Services
Android App Development 06 : Network & Web ServicesAndroid App Development 06 : Network & Web Services
Android App Development 06 : Network & Web ServicesAnuchit Chalothorn
 
SAP ODATA Overview & Guidelines
SAP ODATA Overview & GuidelinesSAP ODATA Overview & Guidelines
SAP ODATA Overview & GuidelinesAshish Saxena
 
Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)Mindfire Solutions
 
SFDC Inbound Integrations
SFDC Inbound IntegrationsSFDC Inbound Integrations
SFDC Inbound IntegrationsSujit Kumar
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 
MuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and ODataMuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and ODataPace Integration
 
Building RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIBuilding RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIGert Drapers
 
Validate your entities with symfony validator and entity validation api
Validate your entities with symfony validator and entity validation apiValidate your entities with symfony validator and entity validation api
Validate your entities with symfony validator and entity validation apiRaffaele Chiocca
 
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...Jitendra Bafna
 
distributing over the web
distributing over the webdistributing over the web
distributing over the webNicola Baldi
 
UserCentric Identity based Service Invocation
UserCentric Identity based Service InvocationUserCentric Identity based Service Invocation
UserCentric Identity based Service Invocationguestd5dde6
 

Semelhante a Learning How to Shape and Configure an OData Service for High Performing Web and Mobile Applications (20)

Wcf data services
Wcf data servicesWcf data services
Wcf data services
 
Gaining the Knowledge of the Open Data Protocol (OData)
Gaining the Knowledge of the Open Data Protocol (OData)Gaining the Knowledge of the Open Data Protocol (OData)
Gaining the Knowledge of the Open Data Protocol (OData)
 
Learning How to Shape and Configure an OData Feed for High Performing Web Sit...
Learning How to Shape and Configure an OData Feed for High Performing Web Sit...Learning How to Shape and Configure an OData Feed for High Performing Web Sit...
Learning How to Shape and Configure an OData Feed for High Performing Web Sit...
 
RESTfulDay9
RESTfulDay9RESTfulDay9
RESTfulDay9
 
JAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with Java
 
Android App Development 06 : Network & Web Services
Android App Development 06 : Network & Web ServicesAndroid App Development 06 : Network & Web Services
Android App Development 06 : Network & Web Services
 
ReST
ReSTReST
ReST
 
SAP ODATA Overview & Guidelines
SAP ODATA Overview & GuidelinesSAP ODATA Overview & Guidelines
SAP ODATA Overview & Guidelines
 
Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)
 
SFDC Inbound Integrations
SFDC Inbound IntegrationsSFDC Inbound Integrations
SFDC Inbound Integrations
 
Rest
RestRest
Rest
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 
MuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and ODataMuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and OData
 
Building RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIBuilding RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPI
 
Validate your entities with symfony validator and entity validation api
Validate your entities with symfony validator and entity validation apiValidate your entities with symfony validator and entity validation api
Validate your entities with symfony validator and entity validation api
 
Troubleshooting.pptx
Troubleshooting.pptxTroubleshooting.pptx
Troubleshooting.pptx
 
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
 
Kantara OTTO slides
Kantara OTTO slidesKantara OTTO slides
Kantara OTTO slides
 
distributing over the web
distributing over the webdistributing over the web
distributing over the web
 
UserCentric Identity based Service Invocation
UserCentric Identity based Service InvocationUserCentric Identity based Service Invocation
UserCentric Identity based Service Invocation
 

Mais de Woodruff Solutions LLC

Developing Mobile Solutions with Azure Mobile Services in Windows 8.1 and Win...
Developing Mobile Solutions with Azure Mobile Services in Windows 8.1 and Win...Developing Mobile Solutions with Azure Mobile Services in Windows 8.1 and Win...
Developing Mobile Solutions with Azure Mobile Services in Windows 8.1 and Win...Woodruff Solutions LLC
 
Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8Woodruff Solutions LLC
 
Pushing Data to and from the Cloud with SQL Azure Data Sync -- TechEd NA 2013
Pushing Data to and from the Cloud with SQL Azure Data Sync -- TechEd NA 2013Pushing Data to and from the Cloud with SQL Azure Data Sync -- TechEd NA 2013
Pushing Data to and from the Cloud with SQL Azure Data Sync -- TechEd NA 2013Woodruff Solutions LLC
 
Developing Mobile Solutions with Azure and Windows Phone VSLive! Redmond 2013
Developing Mobile Solutions with Azure and Windows Phone VSLive! Redmond 2013Developing Mobile Solutions with Azure and Windows Phone VSLive! Redmond 2013
Developing Mobile Solutions with Azure and Windows Phone VSLive! Redmond 2013Woodruff Solutions LLC
 
Connecting to Data from Windows Phone 8 VSLive! Redmond 2013
Connecting to Data from Windows Phone 8 VSLive! Redmond 2013Connecting to Data from Windows Phone 8 VSLive! Redmond 2013
Connecting to Data from Windows Phone 8 VSLive! Redmond 2013Woodruff Solutions LLC
 
AzureConf 2013 Developing Cross Platform Mobile Solutions with Azure Mobile...
AzureConf 2013   Developing Cross Platform Mobile Solutions with Azure Mobile...AzureConf 2013   Developing Cross Platform Mobile Solutions with Azure Mobile...
AzureConf 2013 Developing Cross Platform Mobile Solutions with Azure Mobile...Woodruff Solutions LLC
 
Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8Woodruff Solutions LLC
 
Build Conference Highlights: How Windows 8 Metro is Revolutionary
Build Conference Highlights: How Windows 8 Metro is RevolutionaryBuild Conference Highlights: How Windows 8 Metro is Revolutionary
Build Conference Highlights: How Windows 8 Metro is RevolutionaryWoodruff Solutions LLC
 
Breaking down data silos with the open data protocol
Breaking down data silos with the open data protocolBreaking down data silos with the open data protocol
Breaking down data silos with the open data protocolWoodruff Solutions LLC
 

Mais de Woodruff Solutions LLC (13)

Developing Mobile Solutions with Azure Mobile Services in Windows 8.1 and Win...
Developing Mobile Solutions with Azure Mobile Services in Windows 8.1 and Win...Developing Mobile Solutions with Azure Mobile Services in Windows 8.1 and Win...
Developing Mobile Solutions with Azure Mobile Services in Windows 8.1 and Win...
 
Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8
 
Pushing Data to and from the Cloud with SQL Azure Data Sync -- TechEd NA 2013
Pushing Data to and from the Cloud with SQL Azure Data Sync -- TechEd NA 2013Pushing Data to and from the Cloud with SQL Azure Data Sync -- TechEd NA 2013
Pushing Data to and from the Cloud with SQL Azure Data Sync -- TechEd NA 2013
 
Developing Mobile Solutions with Azure and Windows Phone VSLive! Redmond 2013
Developing Mobile Solutions with Azure and Windows Phone VSLive! Redmond 2013Developing Mobile Solutions with Azure and Windows Phone VSLive! Redmond 2013
Developing Mobile Solutions with Azure and Windows Phone VSLive! Redmond 2013
 
Connecting to Data from Windows Phone 8 VSLive! Redmond 2013
Connecting to Data from Windows Phone 8 VSLive! Redmond 2013Connecting to Data from Windows Phone 8 VSLive! Redmond 2013
Connecting to Data from Windows Phone 8 VSLive! Redmond 2013
 
AzureConf 2013 Developing Cross Platform Mobile Solutions with Azure Mobile...
AzureConf 2013   Developing Cross Platform Mobile Solutions with Azure Mobile...AzureConf 2013   Developing Cross Platform Mobile Solutions with Azure Mobile...
AzureConf 2013 Developing Cross Platform Mobile Solutions with Azure Mobile...
 
Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8
 
Sql Azure Data Sync
Sql Azure Data SyncSql Azure Data Sync
Sql Azure Data Sync
 
Producing an OData feed in 10 minutes
Producing an OData feed in 10 minutesProducing an OData feed in 10 minutes
Producing an OData feed in 10 minutes
 
Build Conference Highlights: How Windows 8 Metro is Revolutionary
Build Conference Highlights: How Windows 8 Metro is RevolutionaryBuild Conference Highlights: How Windows 8 Metro is Revolutionary
Build Conference Highlights: How Windows 8 Metro is Revolutionary
 
Sailing on the ocean of 1s and 0s
Sailing on the ocean of 1s and 0sSailing on the ocean of 1s and 0s
Sailing on the ocean of 1s and 0s
 
Breaking down data silos with OData
Breaking down data silos with ODataBreaking down data silos with OData
Breaking down data silos with OData
 
Breaking down data silos with the open data protocol
Breaking down data silos with the open data protocolBreaking down data silos with the open data protocol
Breaking down data silos with the open data protocol
 

Último

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Último (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

Learning How to Shape and Configure an OData Service for High Performing Web and Mobile Applications

  • 1. #devsum15 Learning How to Shape and Configure an OData Feed for High Performing Web Sites and Applications Chris Woodruff @cwoodruff cwoodruff@live.com
  • 2. Hi, I’m Woody! Chris Woodruff • cwoodruff@live.com • http://chriswoodruff.com • http://deepfriedbytes.com • twitter @cwoodruff
  • 3. VALIDATION CLIENT SIDEBEST PRACTICES AGENDA
  • 4. What are the 2 Sides of OData? SERVER-SIDE (PRODUCER) CLIENT-SIDE (CONSUMER)
  • 6. UNDERSTAND REST The Top Reasons You Need to Learn about Data in Your Windows Phone App
  • 7.
  • 9. WHAT SHOULD YOU KNOW ABOUT REST? Resources REST uses addressable resources to define the structure of the API. These are the URLs you use to get to pages on the web Request Headers These are additional instructions that are sent with the request. These might define what type of response is required or authorization details. Request Verbs These describe what you want to do with the resource. A browser typically issues a GET verb to instruct the endpoint it wants to get data, however there are many other verbs available including things like POST, PUT and DELETE. Request Body Data that is sent with the request. For example a POST (creation of a new item) will required some data which is typically sent as the request body in the format of JSON or XML. Response Body This is the main body of the response. If the request was to a web server, this might be a full HTML page, if it was to an API, this might be a JSON or XML document. Response Status codes These codes are issues with the response and give the client details on the status of the request.
  • 10. REST & HTTP VERBS GET Requests a representation of the specified Requests using GET should only retrieve have no other effect. POST Requests that the server accept the entity enclosed in the request as a new subordinate of the web resource identified by the URI. PUT Requests that the enclosed entity be stored under the supplied URI. DELETE Deletes the specified resource.
  • 11. EXAMPLES OF REST AND ODATA /Products RESOURCE EXPECTED OUTCOMEVERB RESPONSE CODE /Products?$filter=Color eq ‘Red' /Products /Products(81) /Products(881) /Products(81) /Products(81) GET GET POST GET GET PUT DELETE A list of all products in the system A list of all products in the system where the color is red Creation of a new product Product with an ID of 81 Some error message Update of the product with ID of 81 Deletion of the product with ID of 81 200/OK 200/OK 201/Created 200/OK 404/Not Found 204/No Content 204/No Content
  • 13. Get to know the OData Protocol!!!
  • 14. Examples (http://chinookdata.azurewebsites.net) GET serviceRoot/Artists?$filter=Name eq 'Foo Fighters' GET serviceRoot/Artists?$filter=contains(Name, 'Foo') GET serviceRoot/Artists(1)?$expand=Albums GET serviceRoot/Artists(58)/Albums?$orderby=Title desc GET serviceRoot/Artists?$skip=20&$top=10 GET serviceRoot/Artists?$search=AC *** GET serviceRoot/Customer?$filter=Email/any(s:endswith(s, 'contoso.com')) *** GET serviceRoot/$metadata
  • 16. Examples (http://chinookdata.azurewebsites.net) PROPERTIES OF THE CUSTOMER ENTITY • CustomerId • FirstName • LastName • Company • Address • City • State QUERY PROJECTIONS FOR PERFORMANCE GET serviceRoot/Customers?$select= FirstName, LastName, Company GET serviceRoot/Customers?$select= LastName, Address, City, State, Country, PostalCode GET serviceRoot/Customers?$select= FirstName, LastName, Phone, Email • Country • PostalCode • Phone • Fax • Email • SupportRepId
  • 21. Data Caching with Web API OData v4
  • 22. Example Add the CacheCow Server NuGet package to your server project.
  • 23. Example Add the following to your WebApiConfig.cs file: var cacheCowCacheHandler = new CachingHandler(config); config.MessageHandlers.Add(cacheCowCacheHandler); When you get a resource you will get an Etag ETag: W/”002a41972c3d43f0bb14d033907b3f41″ When you make a second request to the same resource, you should send this ETag. The server uses this identifier to check if the resource you requested has changed (remember, the server is the authoritative source). If the resource has indeed changed, it sends you the latest copy. Otherwise, it sends a 304 Not Modified.
  • 25. QUERYABLE ODATAATTRIBUTES AllowedFunctions Consider disabling the any() and all() functions, as these can be 0 5 IgnoreDataMember (not with Queryable) Represents an Attribute that can be placed on a property to specify that the property cannot be navigated in OData query. 0 6 PageSize Enable server-driven paging, to avoid returning a large data set in one query. For more information 0 1 AllowedQueryOptions Do you need $filter and $orderby? Some applications might allow client paging, using $top and $skip, but disable the other query options. 0 2 AllowedOrderByProperties Consider restricting $orderby to properties in a clustered index. Sorting large data without a clustered index is slow. 0 3 AllowedLogicalOperators Consider any logical operators that you do not want to allow 0 4
  • 26. Examples [EnableQuery(AllowedQueryOptions = AllowedQueryOptions.Filter)] [EnableQuery(AllowedLogicalOperators = AllowedLogicalOperators.Equal)] [EnableQuery(AllowedFunctions = AllowedFunctions.AllStringFunctions)] [EnableQuery(AllowedOrderByProperties = "ID")]
  • 27. ODATAATTRIBUTES (CONT) NotExpandable Represents an Attribute that can be placed on a property to specify be used in the $expand OData query option. 0 5 NotNavigable Represents an Attribute that can be placed on a property to specify that the property cannot be navigated in OData query. 0 6 NotSortable Represents an attribute that can be placed on a property to specify that the property cannot be used in the $orderby OData query option. 0 7 NonFilterable Represents an Attribute that can be placed on a property to specify that the property cannot be used in the $filter OData query option. 0 1 UnSortable Represents an Attribute that can be placed on a property to specify that the property cannot be used in the $orderby OData query option. 0 2 NotExpandable Represents an Attribute that can be placed on a property to specify that the property cannot be used in the $expand OData query option. 0 3 NotCountable Represents an Attribute that can be placed on a property to specify that the $count cannot be applied on the property. 0 4 [NonFilterable] [Unsortable] public string Name { get; set; }
  • 28. QUERY SECURITY Consider disabling the any() and all() functions, as these can be slow. 0 6 If any string properties contain large strings— for example, a product description or a blog entry—consider disabling the string functions. 0 7 Consider disallowing filtering on navigation properties. Filtering on navigation properties can result in a join, which might be slow, depending on your database schema. 0 8 Test your service with various queries and profile the DB. 0 1 Enable server-driven paging, to avoid returning a large data set in one query. 0 2 Do you need $filter and $orderby? Some applications might allow client paging, using $top and $skip, but disable the other query options. 0 3 Consider restricting $orderby to properties in a clustered index. Sorting large data without a clustered index is slow. 0 4 Consider restricting $filter queries by writing a validator that is customized for your database. 0 9 Maximum node count: The MaxNodeCount property on [Queryable] sets the maximum number nodes allowed in the $filter syntax tree. The default value is 100, but you may want to set a lower value, because a large number of nodes can be slow to compile. 0 5
  • 29. VALIDATION PATHS Filter Query Represents a validator used to validate a FilterQueryOption based on the ODataValidationSettings. Order By Query Represents a validator used to validate an OrderByQueryOption based on the ODataValidationSettings. OData Query Represents a validator used to validate OData queries based on the ODataValidationSettings. Select Expand Query Represents a validator used to validate a SelectExpandQueryOption based on the ODataValidationSettings. Skip Query Represents a validator used to validate a SkipQueryOption based on the ODataValidationSettings. Top Query Represents a validator used to validate a TopQueryOption based on the ODataValidationSettings.
  • 30. QUERY SECURITY // Validator to prevent filtering on navigation properties. public class MyFilterQueryValidator : FilterQueryValidator { public override void ValidateNavigationPropertyNode( Microsoft.Data.OData.Query.SemanticAst.QueryNode sourceNode, Microsoft.Data.Edm.IEdmNavigationProperty navigationProperty, ODataValidationSettings settings) { throw new ODataException("No navigation properties"); } } // Validator to restrict which properties can be used in $filter expressions. public class MyFilterQueryValidator : FilterQueryValidator { static readonly string[] allowedProperties = { "ReleaseYear", "Title" }; public override void ValidateSingleValuePropertyAccessNode( SingleValuePropertyAccessNode propertyAccessNode, ODataValidationSettings settings) { string propertyName = null; if (propertyAccessNode != null) { propertyName = propertyAccessNode.Property.Name; } if (propertyName != null && !allowedProperties.Contains(propertyName)) { throw new ODataException( String.Format("Filter on {0} not allowed", propertyName)); } base.ValidateSingleValuePropertyAccessNode(propertyAccessNode, settings); } }
  • 34. XODATA Web-based OData Visualizer FIDDLER Free web debugging tool which logs all HTTP(S) traffic between your computer and the Internet. LINQPAD (v3) Interactively query SQL databases (among other data sources such as OData or WCF Data Services) using LINQ, as well as interactively writing C# code without the need for an IDE. ODATA VALIDATOR Enable OData service authors to validate their implementation against the OData specification to ensure the service interoperates well with any OData client. TESTING/DEBUGGING ODATA www.websitename.com
  • 36. Demo Show How to Consume an OData Feed in an Universal App
  • 38. ODATA WORKSHOP 01 02 03 04 TESTING/DEBUGGING ODATA DEVELPING CLIENT SIDE SOLUTIONS • Web Apps using Javascript to consume Odata • iOS Swift development for native iPhone and iPad apps • Windows 8.1 and Windows Phone apps C# and WinJS • Android development using Java • Using Xamarin for consuming OData LEARNING THE PROTOCOL • The Metadata and Service Model of OData • URI Conventions of OData • Format Conventions of OData • OData HTTP Conventions and Operations DEVELPING SERVER SIDE SOLUTIONS • ASP.NET Web API • Advanced Performance Tips and Best Practices Go to http://ChrisWoodruff.com for more details and pricing
  • 39. THANK YOU Find me around the conference and would enjoy chatting Email: cwoodruff@live.com Twitter: @cwoodruff

Notas do Editor

  1. 200 OK -- Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action. 201 Created -- The request has been fulfilled and resulted in a new resource being created. 204 No Content -- The server successfully processed the request, but is not returning any content. Usually used as a response to a successful delete request. 404 Not Found -- The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.
  2. // Disable any() and all() functions. [Queryable(AllowedFunctions= AllowedFunctions.AllFunctions & ~AllowedFunctions.All & ~AllowedFunctions.Any)]
  3. // Validator to prevent filtering on navigation properties. public class MyFilterQueryValidator : FilterQueryValidator { public override void ValidateNavigationPropertyNode( Microsoft.Data.OData.Query.SemanticAst.QueryNode sourceNode, Microsoft.Data.Edm.IEdmNavigationProperty navigationProperty, ODataValidationSettings settings) { throw new ODataException("No navigation properties"); } } // Validator to restrict which properties can be used in $filter expressions. public class MyFilterQueryValidator : FilterQueryValidator { static readonly string[] allowedProperties = { "ReleaseYear", "Title" }; public override void ValidateSingleValuePropertyAccessNode( SingleValuePropertyAccessNode propertyAccessNode, ODataValidationSettings settings) { string propertyName = null; if (propertyAccessNode != null) { propertyName = propertyAccessNode.Property.Name; } if (propertyName != null && !allowedProperties.Contains(propertyName)) { throw new ODataException( String.Format("Filter on {0} not allowed", propertyName)); } base.ValidateSingleValuePropertyAccessNode(propertyAccessNode, settings); } }