我讨厌出于许多不同的原因使用服务引用,而是使用接口和System.ServiceModel.ChannelFactory
我希望在连接到WCF数据服务时能够使用类似的东西。
我的意思是,当我创建DataService端点时,它只是DataService为什么我不能在创建客户机时创建一个DataServiceContext并访问MyDataService中的所有iqueryable。
如
普通的
public interface IMyDataService
{
public IQueryable<Foo> Foos {get;set;}
public IQueryable<OtherFoo> OtherFoos {get;set;}
}
服务器
public class MyDataService : IMyDataService
{
public IQueryable<Foo> Foos {get;set;}
public IQueryable<OtherFoo> OtherFoos {get;set;}
}
public class DataService : DataService<MyDataService>
{
}
顾客
var context = new DataServiceContext<IMyDataService>();
var foo = context.Foos.First(f=>f.Id = 5);
var otherFoos = contact.OtherFoos.Where(of=>of.width > 6);
编辑:我有一个解决方案,我创建了IMyDataService的代理类,但据我所知,这在服务器上是相当困难的。任何人都知道使用此处详述的方法创建代理对性能的影响:
http://www.codeproject.com/KB/cs/dynamicproxy.aspx