I hate using service references for many different 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'm creating the DataService Endpoint it's just DataService why can't I new up a DataServiceContext when creating the client and have access to all the IQueryables in MyDataService.
eg
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>开发者_Python百科 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 a proxy class of IMyDataService however it's my understanding that this would be pretty hard on a server. Anyone know anything about the performance impact of creating a proxy using the method detailed here: http://www.codeproject.com/KB/cs/dynamicproxy.aspx
精彩评论