WCF Data Service (OData) Recommended Practices
WCF Data Service Dos and Don`t dos
- Avoid using "ExecuteStoreCommand" because it cause several problem in serialization and as a result $select query will fail on any property other than string Read More...
- Prefer creating separate project for data models that will be easier to ship.
- Must add a service operation 'Version' that should display service version as XML response it will help automated clients to dynamically modify there behavior.
- Avoid using custom parameters that will not be passed to next page and will cause problem in case of paging Read More...
- If using external entity provider like Devart for Oracle then make sure that you have Unicode=True setting turned on for global application several provider have it off by default. Read More...
- Prefer handling exception centrally at service level and throw a grace full error massage for known issues with your implementations.
- Avoid using large and complex queries in <DefiningQuery> tag of storage model
- if you have extra fields in your conceptual model then initialize them using <QueryView> of conceptual model, it can also be used for entity level joins.
- If your project have multiple service classes then prefer to keep common configuration code in a separate class and override as required.
- Always add cross site scripting support to support client like silver light, all you need to add a crosssite.xml file to service root.
- Must add JSONP support to service via get protocol because it is well accepted on device world.
- Configure your model to proper display of data over the browser as feeds.
- Plan versioning in early phase of development
- for authentication Override OnStartProcessingRequest add add your custom authentication logic
- For authorization use change/ query interceptors
- Use reflection provider for exposing your custom classes without using EF
- Write custom data provider if you need to have good control of data service and want to use data service with multiple data sources
- Be carefull if using ObjectMaterialized even because it does not get fired in case of $select (projection) query. Read More...
- Avoid Creating Service Operation because they are not well supported by Data Service Client libraries http://msdn.microsoft.com/en-us/library/hh230677.aspx
- If creating Service Operation then prefer creating GET method because POST is not supported by client library.
- If creating EDMX from a view make sure the keys it is generating is correct and try to keep minimum number of columns in key. This will solve several run time problems.EDMX generator is not good in figuring keys for views and just creates a key by picking all the column that marked as NOT_NULL here is an example
- Avoid building a Data Service (EDMX) with no Primary Key in Table or Inferred Primary key it may lead you strange bugs that will be hard to find Read more...
Best Practices: Creating OData Services Using Windows Communication Foundation (WCF) Data Services