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 !

相关问答

更多

洪水填充算法(Flood fill algorithm)

除了推动堆栈中的每个像素之外,尝试在推入堆栈中的新位置之前尽可能多地填充像素。 请参阅维基百科文章进行讨论。 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.

洪水填充算法计算房间(Flood Fill Algorithm that counts rooms)

懒得试试你的代码,但在这里有些东西(有些已经在评论中提到过): 你在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,...

三维阵列上的三维洪水填充算法(Java)(3D Flood Fill Algorithm on a 3D Array (Java))

几件事: 休息并不意味着你的想法。 你应该使用return来保留这个功能 您可能想要在调用相邻单元格的函数之前检查您是否位于域的边界(否则,它将崩溃) 使用递归填充洪水是很好的...仅用于教育目的。 使用队列效率更高 一个简单的事情就是尝试一下,看它是否有效! Several things: break does not mean what you think it does. You should use return to leave the function You may want to ...

为什么使用Flood Fill算法时会出现java.lang.StackOverflowError?(Why do I get java.lang.StackOverflowError when using Flood Fill algorithm?)

StackOverflowException意味着,你的递归对你的内存来说太深或者不会结束。 试试更小的图像。 当这不能解决问题时,递归结束条件会出现问题。 (setPixel()和getPixel是否真的改变图像?写一个JUnitTest ) 你也应该简化你的setPixel和getPixel方法。 他们太复杂了。 对于您设置的每个像素,或者创建一个新的BufferedImage-Instance,然后在设置一个像素后进行处理。 您可以存储和重新使用BufferedImage。 StackOve...

图像泛光填充后的不同颜色(Different color after image flood fill)

你那里有一个灰度图像。 您不能在灰度图像上使用绿色。 这就是它变成浅灰色的原因。 你需要: 事先将图像转换为RGB 确保在Java中读取/转换图像为RGB 最后一个选项更安全,因为它在将来的图像上不会失败。 这是我在网络上发现的一些代码,据说可以转换为灰度。 一个小的修改,你有你需要的东西,以确保你正在处理彩色图像: public static BufferedImage convertToGrayscale(BufferedImage source) { BufferedImageO...

三维表面重建算法(3D surface Reconstruction algorithm)

您提到的“轮廓”的技术术语是“等值线”。 给定一组等值线,首先需要在3D中构建点云(只是3D空间中的点集合)。 你分两个阶段做到这一点。 首先以均匀的间隔对每个等值线进行采样,得到2D点,然后将点提高到适当的高度。 通过在任何地方跟踪它,可以很容易地以均匀的间隔对线进行采样。 您可以通过从最外面的线开始并逐行向内查找线来了解线的高度,删除跟踪的每条线并跟踪您跟踪的线数。 当然,您需要事先知道线之间的高度差是什么,最外线(或任何其他可用作参考的线)的高度是多少? 拥有3D点云后,您可以使用多种曲面重...

填充Numpy阵列第三维的清洁方法(Clean Way to Fill Third Dimension of Numpy Array)

也许: >>> 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.]) >>> ...

MySQL 3D“洪水填充”实施(MySQL 3D “Flood Fill” Implementation)

不应在SQL中实现快速泛洪填充。 您可以将所有需要的数据加载到适当的结构(可能是某些图形表示或3d数组,具体取决于数据的密度),并运行堆栈/队列或您可以用手头的编程语言编写的任何其他实现。 根据定义,泛洪填充是递归的(即使它通常由循环实现),并且SQL不擅长递归,也不擅长循环。 但是有一些东西可能会在mysql中使用,即使它不是一个普通的SQL解决方案。 有一个特殊的引擎来处理图形 - OQGRAPH 。 它可以在MariaDB中使用,可能可以安装到MySQL。 它支持组合图的有效存储,其中网格只...

相关文章

更多

form load 的问题

baseinfoForm.form.load({ url: '/Url/Institution/In ...

Unable to load configuration.

严重: Exception starting filter struts2 Unable to lo ...

EXT4 Store Load For Gird Exception

Gird Store 自动装载时附加一个参数user,而在pagingtoolbar上点击获取下一页数 ...

解决Eclipse无法打开“Failed to load the JNI shared library”

今天在刚买的笔记本上打开eclipse出现Failed to load the JNI shared ...

Hadoop Could not load native gpl library异常解决

Hadoop Could not load native gpl library异常解决 完整异常: ...

hibernate 多表 join 查询发现还是会重新load one-to-many 子表

原来的系统性能慢,今天在做性能调优,发现有一个多表查询存在性能问题。 我的hbm.xml配置文件 ...

hibernate延迟加载

要说延迟加载,先来了解一下hibernate中的load和get。要说延迟加载,先来了解一下hiber ...

tomcat6启动异常 Could not load com.mysql.jdbc.SQLError的解决方法

我用的tomcat是​apache-tomcat-6.0.36,在启动的时候出现以下的异常:Could ...

tomcat6 启动加载项目时报内存溢出 急

在windows系统下。 我将一个大的项目拷贝到tomcat/webapps该目录下,在启动tomc ...

类加载方法

Class.forName("binary name"); 加载并对类变量进行初始化 ...

最新问答

更多

sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)

否(它不会使它们无法访问),是(您可以在没有停机的情况下运行它)。 sp_updatestats可以在没有停机的情况下针对实时数据库运行。 No (it doesn't make them inaccessible), and Yes (you can run it without downtime). sp_updatestats can be run against a live database without downtime.

如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)

最终,我们选择了使用Spark Framework for Java实现的后端REST API。 这可能不是最强大的,用户反馈一直是个问题。 我们将命令行界面拆分为提交REST调用,并将结果显示给用户。 Ultimately, we chose to go the route of having a backend REST API that was implemented with the Spark Framework for Java. This may not be the most r

AESGCM解密失败的MAC(AESGCM decryption failing with MAC)

您不能将Encoding.UTF8.GetString应用于任意二进制数据。 它只能解码使用UTF-8编码字符串的结果的字节。 .net实现将默默地破坏数据,而不是默认情况下抛出异常。 您应该使用Base64: Convert.FromBase64String和Convert.ToBase64String You can't apply Encoding.UTF8.GetString to arbitrary binary data. It can only decode bytes that

Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)

我希望能看到更多你的Sass代码等,但我的猜测是你需要在所有嵌套行上使用nest行为。 在我看来,基金会在Sass中的行主要是为了在一个层面上使用。 嵌套在另一行中的任何行都应使用nest行为,除非您希望在列上添加额外的填充。 在你的CodePen中,我能够通过向所有行添加一类collapse来修复列上填充的问题,我认为这与执行$behavior: nest相同$behavior: nest在Sass中$behavior: nest :

湖北京山哪里有修平板计算机的

京山有个联想的专卖店,那里卖平板电脑,地址在中百前面的十字路口右拐 ,他们应该会提供相关的维修服务。

SimplePie问题(SimplePie Problem)

我怀疑由于内容的性质(包含代码),stackoverflow提要不起作用。 我使用许多feed解析器看似“正常”的feed有类似的问题,尽管我最近运气最多的是Zend_Feed。 试试吧 I suspect the stackoverflow feed is not working due to the nature of the content (contains code). I have had similar issues with seemingly "normal" feeds us

在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)

是的,您可以通过getApplicationContext()任意数量的时间(后台任务), getApplicationContext()仅返回应用程序的context 。 Yes, you can pass getApplicationContext() any number of time (Background Tasks ) you want, getApplicationContext() simply returns context of the application.

HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)

这是我最终做的事情: 我无法以这种方式提供完全访问权限,而是在project level folder中设置了一个虚拟HTML页面,该页面单击自身以重定向到位于separate, non-project util folder的HTML文件。 这允许我保留除了那个之外的所有内容,非常小的文件分开但不存在文件访问问题。 Here is what I ended up doing: I wasn't able to provide full access exactly this way, but

为什么我会收到链接错误?(Why do I get a linker error?)

看起来您的编译器错误地将名称引入到全局名称空间中,而不是C ++ 11 3.5 / 7中指定的最内层名称空间( Bushman ): 如果没有找到具有链接的实体的块范围声明来引用某个其他声明,那么该实体是最内层封闭名称空间的成员。 代码按照预期在GCC上编译: http : //ideone.com/PR4KVC 你应该能够通过在构造函数的块作用域中声明它之前(或代替它)在正确的名称空间中声明该函数来解决该bug。 但是,我无法访问您的编译器来测试它。 It looks like your co

如何正确定义析构函数(How to properly define destructor)

在C ++中,你需要手动释放内存。 没有垃圾收集器。 您显然需要在析构函数内手动释放内存。 如果您使用new分配内存,则需要对在deconstructor中使用new分配的每个资源使用delete ,例如: class1::~class1(void) { delete resource1; delete resource2; etc... } In C++ you need to free the memory manually. There's no garbage