Your SlideShare is downloading. ×
  • Like
  • Save
BASTA 2013: Custom OData Provider
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

BASTA 2013: Custom OData Provider

  • 1,180 views
Published

Im zweiten Teil seiner OData Session zeigt Rainer Stropek, wie man eigene OData-Provider entwickelt. In einem durchgängigen Beispiel demonstriert er, wie man erst einen LINQ-Provider und darauf …

Im zweiten Teil seiner OData Session zeigt Rainer Stropek, wie man eigene OData-Provider entwickelt. In einem durchgängigen Beispiel demonstriert er, wie man erst einen LINQ-Provider und darauf aufbauend einen OData-konformen REST Service erstellt und von verschiedenen Programmiersprachen und Tools darauf zugreift. In der Session werden Grundkenntnisse von OData und LINQ vorausgesetzt.

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,180
On SlideShare
0
From Embeds
0
Number of Embeds
6

Actions

Shares
Downloads
0
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Rainer StropekCustom Odata Providers
  • 2. Introduction• You all know what OData is? – Short demo to introduce OData?• You are all familiar with LINQ & IQueryable? – Short demo to introduce IQueryable?
  • 3. What is the basic idea of OData and IQueryable regarding databasequeries?ARCHITECTURE
  • 4. Architecture of C#, OData and IQueryableCompiler Generator Grammar rules Tree Source Lexer, Parser Generator Target (Syntax Tree) Interpreter
  • 5. Architecture of C#, OData and IQueryable C# Compiler BCL C# IL Expression TreeOData Query (URI) SQL OData Entity runtime Framework Interpret or rewrite
  • 6. Typical ArchitectureClients Load Balancer DB Failover Web Farm Cluster Cloud
  • 7. Solution = Sharding Clients Load Balancer DB Load Web Farm Balancing Cluster of Failover Cloud Clusters
  • 8. How can we build a custom IQueryable?CUSTOM IQUERYABLE
  • 9. Custom IQueryable• Use IQToolkit if possible• Derive your implementation from QueryProvider• Implement two virtual methods – object Execute(Expression expression) – string GetQueryText(Expression expression) (Optional)
  • 10. Using Custom IQueryable• Expression tree is received by query provider• We have to rewrite and run it to all e.g. sharding databases
  • 11. Implement Queryable• Use .NET‘s visitor pattern to examine and rewrite expression tree• AnalyzeQueryVisitor – Verifies that query is ok (e.g. must contain top-clause, etc.) – Stores reference to e.g. Take and Skip clauses
  • 12. How can we build a custom OData provider?CUSTOM ODATA PROVIDER
  • 13. Custom OData Building Blocks• Derive from DataService<T> – Main entry point for developing a WCF Data Service• Implement IServiceProvider to provide... – ...IDataServiceMetadataProvider • Build custom metadata • Build OData metadata with e.g. reflection – ... IDataServiceQueryProvider • Provide an underlying IQueryable for query execution
  • 14. Workflow for OData Query(simplified) Get metdata service Get query provider Create data- source Set current data source Initialize service Get IQueryable used for getting Provide Resolve resource data metdata set Get query root (IQueryable)
  • 15. IDataServiceMetadataProvider• ResourceSet consisting of ResourceType objects (=entity types)• CustomDataServiceMetadataProvider is a simple generic implementation of IDataServiceMetadataProvider
  • 16. IDataServiceMetadataProviderpublic interface IDataServiceMetadataProvider{ Service Ops not string ContainerName { get; } covered here string ContainerNamespace { get; } IEnumerable<ResourceSet> ResourceSets { get; } IEnumerable<ServiceOperation> ServiceOperations { get; } IEnumerable<ResourceType> Types { get; } IEnumerable<ResourceType> GetDerivedTypes(ResourceType resourceType); ResourceAssociationSet GetResourceAssociationSet( ResourceSet resourceSet, ResourceType resourceType, ResourceProperty resourceProperty); bool HasDerivedTypes(ResourceType resourceType); bool TryResolveResourceSet(string name, out ResourceSet resourceSet); bool TryResolveResourceType(string name, out ResourceType resourceType); bool TryResolveServiceOperation(string name, out ServiceOperation serviceOperation);}
  • 17. IDataServiceQueryProvider• Provides root IQueryable for a given resource set• CustomDataServiceProvider is a simple generic implementation of IDataServiceQueryProvider
  • 18. IDataServiceQueryProviderpublic interface IDataServiceQueryProvider{ object CurrentDataSource { get; set; } bool IsNullPropagationRequired { get; } object GetOpenPropertyValue(object target, string propertyName); IEnumerable<KeyValuePair<string, object>> GetOpenPropertyValues( object target); object GetPropertyValue(object target, ResourceProperty resourceProperty); IQueryable GetQueryRootForResourceSet(ResourceSet resourceSet); ResourceType GetResourceType(object target); object InvokeServiceOperation(ServiceOperation serviceOperation, object[] parameters);}
  • 19. Linking Custom OData & Custom LINQ Provider
  • 20. Further Readinghttp://www.software-architects.com