首页 \ 问答 \ DomainContext加载(DomainContext Load)

DomainContext加载(DomainContext Load)

我尝试通过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)中用作类型参数'TEntity'。 ,System.Action>,object)'。 没有从'SilverlightApplication1.Book'到'System.ServiceModel.DomainServices.Client.Entit的隐式引用转换

怎么解决?


I tried to load a entity by domainservice(async) in on line of code like:

context.Load<Book>(
context.Books.Where(b => b.BookID == 1),
(s, e) =>
{
    _book = e.Results;
},
null);

But I got following error: The type 'SilverlightApplication1.Book' cannot be used as type parameter 'TEntity' in the generic type or method 'System.ServiceModel.DomainServices.Client.DomainContext.Load(System.ServiceModel.DomainServices.Client.EntityQuery, System.Action>, object)'. There is no implicit reference conversion from 'SilverlightApplication1.Book' to 'System.ServiceModel.DomainServices.Client.Entit

how to fix it?


原文:https://stackoverflow.com/questions/3644485
更新时间:2024-04-23 17:04

最满意答案

几件事:

  • 休息并不意味着你的想法。 你应该使用return来保留这个功能
  • 您可能想要在调用相邻单元格的函数之前检查您是否位于域的边界(否则,它将崩溃)
  • 使用递归填充洪水是很好的...仅用于教育目的。 使用队列效率更高
  • 一个简单的事情就是尝试一下,看它是否有效!

Several things:

  • break does not mean what you think it does. You should use return to leave the function
  • You may want to check whether you are at the boundary of your domain before calling the function for the adjacent cells (otherwise, it will crash)
  • using a recursion for a flood fill is great... for educational purpose only. Using a queue is much more efficient
  • a simple thing is to try it out and see whether it works !

相关问答

更多
  • 除了推动堆栈中的每个像素之外,尝试在推入堆栈中的新位置之前尽可能多地填充像素。 请参阅维基百科文章进行讨论。 Instead of pushing every pixel on the stack, try to fill as many pixels as possible horizontally before pushing a new position on the stack. See the Wikipedia article for a discussion.
  • 懒得试试你的代码,但在这里有些东西(有些已经在评论中提到过): 你在map[][]检查递归调用 是的,你有这样的: if (x < 0 || y < 0 || x > map.length || y > map[0].length ) return; 但这并不好(甚至是无用的),因为递归调用可以访问高达+2和-1索引越界。 也应该是>= map[0].length 。 我会删除,如果完全,而是使用: if (x> 0) floodFill(x-1,y, oldChar, newC ...
  • 几件事: 休息并不意味着你的想法。 你应该使用return来保留这个功能 您可能想要在调用相邻单元格的函数之前检查您是否位于域的边界(否则,它将崩溃) 使用递归填充洪水是很好的...仅用于教育目的。 使用队列效率更高 一个简单的事情就是尝试一下,看它是否有效! Several things: break does not mean what you think it does. You should use return to leave the function You may want to check ...
  • StackOverflowException意味着,你的递归对你的内存来说太深或者不会结束。 试试更小的图像。 当这不能解决问题时,递归结束条件会出现问题。 (setPixel()和getPixel是否真的改变图像?写一个JUnitTest ) 你也应该简化你的setPixel和getPixel方法。 他们太复杂了。 对于您设置的每个像素,或者创建一个新的BufferedImage-Instance,然后在设置一个像素后进行处理。 您可以存储和重新使用BufferedImage。 StackOverflow ...
  • 你那里有一个灰度图像。 您不能在灰度图像上使用绿色。 这就是它变成浅灰色的原因。 你需要: 事先将图像转换为RGB 确保在Java中读取/转换图像为RGB 最后一个选项更安全,因为它在将来的图像上不会失败。 这是我在网络上发现的一些代码,据说可以转换为灰度。 一个小的修改,你有你需要的东西,以确保你正在处理彩色图像: public static BufferedImage convertToGrayscale(BufferedImage source) { BufferedImageOp op ...
  • 您提到的“轮廓”的技术术语是“等值线”。 给定一组等值线,首先需要在3D中构建点云(只是3D空间中的点集合)。 你分两个阶段做到这一点。 首先以均匀的间隔对每个等值线进行采样,得到2D点,然后将点提高到适当的高度。 通过在任何地方跟踪它,可以很容易地以均匀的间隔对线进行采样。 您可以通过从最外面的线开始并逐行向内查找线来了解线的高度,删除跟踪的每条线并跟踪您跟踪的线数。 当然,您需要事先知道线之间的高度差是什么,最外线(或任何其他可用作参考的线)的高度是多少? 拥有3D点云后,您可以使用多种曲面重建算法中的 ...
  • 也许: >>> m = np.zeros((2,2,3)) >>> m[:] = [10,20,3] >>> m array([[[ 10., 20., 3.], [ 10., 20., 3.]], [[ 10., 20., 3.], [ 10., 20., 3.]]]) >>> m[0,0] array([ 10., 20., 3.]) >>> m[0,1] array([ 10., 20., 3.]) >>> m[1,0 ...
  • 不应在SQL中实现快速泛洪填充。 您可以将所有需要的数据加载到适当的结构(可能是某些图形表示或3d数组,具体取决于数据的密度),并运行堆栈/队列或您可以用手头的编程语言编写的任何其他实现。 根据定义,泛洪填充是递归的(即使它通常由循环实现),并且SQL不擅长递归,也不擅长循环。 但是有一些东西可能会在mysql中使用,即使它不是一个普通的SQL解决方案。 有一个特殊的引擎来处理图形 - OQGRAPH 。 它可以在MariaDB中使用,可能可以安装到MySQL。 它支持组合图的有效存储,其中网格只是一种特殊 ...

相关文章

更多

最新问答

更多
  • CSS修复容器和溢出元素(CSS Fix container and overflow elements)
  • SQL多个连接在与where子句相同的表上(SQL Multiple Joins on same table with where clause)
  • nginx 80端口反向代理多个域名,怎样隐藏端口的
  • xcode提醒样式,swift 3(xcode alert style, swift 3)
  • 在Chrome控制台中调试JavaScript(debugging javascript in Chrome console)
  • Javascript - 试图围绕自定义事件(Javascript - Trying to wrap my head around custom events)
  • 边栏链接不可点击(Sidebar links aren't clickable)
  • 使用recpatcha gem时如何显示其他表单错误?(How do I display other form errors when using the recpatcha gem?)
  • boost.python避免两次注册内部类,但仍然在python中公开(boost.python Avoid registering inner class twice but still expose in python)
  • Android 现在软件很少吗?以后会多起来吗
  • 如何在ActiveAdmin 0.5.0中为资源全局指定预先加载?(How to specify eager loading globally for a resource in ActiveAdmin 0.5.0?)
  • matlab代码为黄金比例持续分数(matlab code for golden ratio continued fraction)
  • Android浏览器触摸事件位置(Android browser touch event location)
  • 将cURL输出分配给Bash中的变量(Assign output to variable in Bash)
  • 我如何在MVC视图上没有时间获取当前日期(how i can get current date without time on MVC view)
  • sql连接函数(sql join of function)
  • 为什么在Xamarin Media插件中使用ImageSource.FromStream而不是FromFile?(Why use ImageSource.FromStream instead of FromFile in Xamarin Media plugin?)
  • 这段代码是否真的可以防止SQL注入?(Will this code actually work against SQL-injection? [duplicate])
  • 信阳方远计算机学校大专证被国家认可么
  • React / Rails AJAX POST请求返回404(React/Rails AJAX POST request returns 404)
  • Android与php服务器交互(Android interact with php server)
  • 自动刷新QTableWidget可能吗?(Refresh QTableWidget automatically possible?)
  • JVM / Compiler优化对象的未使用属性(optimization of unused properties of object by JVM / Compiler)
  • 插入表格时,乌克兰字符会更改为问号(Ukrainian character change to question mark when insert to table)
  • 在头文件中包含异常类(Including an exception class in a header file)
  • 完成c#中的执行后关闭sqlcmd(Close sqlcmd after finishing executing in c#)
  • 使用软导航栏正确检测屏幕尺寸(Detecting screensize correctly with soft navigation bar)
  • Typescript:从输入更新值(Typescript : update value from input)
  • 如何在执行某些行后仅在断点处停止?(How to only stop at a breakpoint after some line was executed?)
  • 以未定义的元素在JSON中循环(loop in JSON with undefined elements)