我已经使用RIA Services创建了一个简单的Silverlight应用程序。域服务类使用LINQ-to-SQL类作为其DataContext。
在我的Silverlight应用程序中,这可以正常工作:
CMSContext db = new CMSContext();
gridTest.ItemsSource = db.Files;
db.Load(db.GetFilesQuery());
但是我无法做到这一点,例如:
db.Load(from f in db.GetFilesQuery() where f.Id > 2 select f);
编译器错误:
Error 5 The type arguments for method 'System.ServiceModel.DomainServices.Client.DomainContext.Load<TEntity>(System.ServiceModel.DomainServices.Client.EntityQuery<TEntity>)' cannot be inferred from the usage. Try specifying the type arguments explicitly. C:\SilverLight\Silverlight 4 Projects\RIATest2\RIATest2\MainPage.xaml.cs 35 4 RIATest2
Error 4 Could not find an implementation of the query pattern for source type 'System.ServiceModel.DomainServices.Client.EntityQuery<RIATest2.Web.File>'. 'Where' not found. C:\SilverLight\Silverlight 4 Projects\RIATest2\RIATest2\MainPage.xaml.cs 35 22 RIATest2
有小费吗?
更新:
解决方案是添加以下内容:
using System.ServiceModel.DomainServices.Client;
最佳答案
解:
using System.ServiceModel.DomainServices.Client;