开发者

How do I implement IDataServiceMetadataProvider and tell my Data Service to use that custom provider?

开发者 https://www.devze.com 2022-12-10 05:28 出处:网络
There\'s no obvious entry point for implementing a custom provider for an ADO.NET Data Service us开发者_如何学Cing IDataServiceMetadataProvider, and then telling a Data Service to use that provider. H

There's no obvious entry point for implementing a custom provider for an ADO.NET Data Service us开发者_如何学Cing IDataServiceMetadataProvider, and then telling a Data Service to use that provider. Has anyone had any luck in this area? I've tried implementing this interface on my Data Source class, but none of my breakpoints are hit. There is also no (obvious) way to set the provider from the Data Service's DataServiceConfiguration parameter passed in to the InitializeService function.

Any help would be appreciated. Thanks!

Data Services Providers (ADO.NET Data Services)

IDataServiceMetadataProvider Members


We are looking at revising some of the documentation for these interfaces for RTM. In the meantime , to get the Data Services runtime to pick up your IDataServiceMetadataProvider implementation , you will need to implement the IServiceProvider interface on your Data Service class .

IServiceProvider on MSDN

Sample :

public class northwindService:DataService<northwindContext> , IServiceProvider 
{
   public object GetService(Type serviceType) 
   {
      if (serviceType == typeof(IDataServiceMetadataProvider )) {
        //return instance of type which implements IDataServiceMetadataProvider 
       }
     return null;
    }  
}


Just to add to Phani reply, you need to make sure that you return both IDataServiceMetadataProvider and IDataServiceQueryProvider from the GetService call. For rest of the interfaces, you have a choice to return it from GetService or implement it on your DataSource class.

Hope this helps.

Thanks Pratik

0

精彩评论

暂无评论...
验证码 换一张
取 消