Factory Client Channel for WCF Data Services

I hate using service references for various reasons, instead I use interfaces and System.ServiceModel.ChannelFactory

I would like to be able to use something similar when connecting to WCF data services.

I mean, when I create a DataService endpoint, it’s just a DataService, why can’t I update the DataServiceContext when I create the client and access all IQueryables in MyDataService.

eg,

Are common

public interface IMyDataService
{
  public IQueryable<Foo> Foos {get;set;}
  public IQueryable<OtherFoo> OtherFoos {get;set;}
}

Server

public class MyDataService : IMyDataService
{
  public IQueryable<Foo> Foos {get;set;}
  public IQueryable<OtherFoo> OtherFoos {get;set;}
}
public class DataService : DataService<MyDataService>
{
}

Client

var context = new DataServiceContext<IMyDataService>();
var foo = context.Foos.First(f=>f.Id = 5);
var otherFoos = contact.OtherFoos.Where(of=>of.width > 6);

Edit: I have a solution where I create the proxy class IMyDataService, but I understand that it will be quite difficult on the server. Everyone knows about the performance impact of creating a proxy server using the method described here: http://www.codeproject.com/KB/cs/dynamicproxy.aspx

+5

All Articles