我尝试通过domainservice(async)在代码行中加载一个实体,如下所示:
context.Load<Book>(
context.Books.Where(b => b.BookID == 1),
(s, e) =>
{
_book = e.Results;
},
null);但是我得到了以下错误:类型'SilverlightApplication1.Book‘不能用作泛型类型或方法'System.ServiceModel.DomainServices.Client.DomainContext.Load(System.ServiceModel.DomainServices.Client.EntityQuery,System.Action>,object)中的类型参数'TEntity’。没有从“SilverlightApplication1.Book”到'System.ServiceModel.DomainServices.Client.Entit的隐式引用转换
如何修复它?
发布于 2010-09-08 03:28:46
如果您需要使用EntityQuery,请查看堆栈跟踪,它会给出解决方案。
在DomainService上(在服务器上)实现方法'GetBookById‘:
公共IQueryable GetBookById(int Id)
{
this.ObjectContext.Book.Where(r => r.Id == Id);
}
然后像这样加载数据:
EntityQuery查询= context.GetBookByIdQuery(1);
Context.Load( OnBookLoaded,OnBookLoaded,null);私有空查询(LoadOperation lo)
{
//按需处理数据,注意:使用'lo.Entities‘有加载的数据
}
https://stackoverflow.com/questions/3644485
复制相似问题