标签:sre property ati ade ros top imp blank put
http://martinwilley.com/net/data/wcfds.html
Formerly "Astoria" and "ADO.Net Data Services", this is the .Net ODATA implementation - ODATA being RESTful HTTP/JSON/ATOM xml access to databases.
HTTP verbs: GET is get, POST is insert, PUT is update, MERGE is partial update, DELETE is delete
NB: PUT,MERGE and DELETE may be blocked by proxies/firewalls, so add the X-HTTP-Method header can be added to a POST request
Reference System.Data.Services.Client.dll. The VS2010 item template for the endpoint is "WCF Data Service". The svc code behind is a DataService<T> with a static InitializeService() method which should expose a IQueryable<T> getter.
DataService<T> can be an Entity Framework ObjectContext, which exposes the ObjectSets (tables).
For custom classes that are exposed, add a [DataServiceKeyAttribute(pk)] to the class to denote the primary key (for http://localhost/wcfds.svc/custom(‘ALFKI‘) gets). For POCOs, add [DataContract(IsReference=true)] so properties are serialized as objects, not values (i.e. product.Category refers to a Category object).
You can secure with the standard IIS/web.config settings including Windows, asp.net forms etc.
In the client library, you can set context.Credentials = new NetworkCredential(username, password) or use the context.SendingRequest event to set request headers such as Authorization.
In server InitializeService, configure SetEntitySetAccessRules
In InitializeService, config.SetServiceOperationAccessRule("*", ServiceOperationRights.All); as applicable/
Expose sprocs as service operations: [WebGet]/[WebInvoke] methods- input parameters must be primitives, return must be primitive or IEnumerables/IQueryable.
Adding a service reference to an ODATA service creates a proxy derived from DataServiceContext which looks like a normal EF ObjectContext. (MSDN concepts)
For data-binding, wrap the objectsets in DataServiceCollection which extends ObservableCollection.
标签:sre property ati ade ros top imp blank put
原文地址:http://www.cnblogs.com/freeliver54/p/6912548.html