(我也在使用 .NET 4.0 和 VS 2010。)
我创建了一个返回复杂类型的函数导入,如 http://msdn.microsoft.com/en-us/library/bb896231.aspx。函数导入和新的复杂类型出现在我的 .edmx 文件和 Designer.cs 文件中。但是,当我在浏览器中查看服务时,该函数不会出现,并且当我在客户端项目中添加或更新服务引用时,该函数也不会出现在那里 - 正如预期的那样,给出第一个结果。
创建导入的函数并使用它在概念上似乎非常简单和直接,人们会认为它会起作用,正如 Microsoft 的分步说明似乎建议的那样: http://msdn.microsoft.com/en-us/library/cc716672.aspx#Y798(该文章显示了 SP 返回实体类型 - 我也尝试过这个,但它没有也不为我工作)。
这篇博客文章展示了向 DataService 类添加一个方法,Microsoft 的说明省略了该方法: http://www.codegain.com/articles/wcf/miscellaneous/how-to-use-stored-procedure-in-wcf-data-service.aspx 我尝试添加一种方法返回一个实体类型列表,另一个返回复杂类型列表,但仍然没有成功。我仍然无法直接通过浏览器或通过服务引用从客户端应用程序访问这些功能。
预先感谢您对此提供的任何帮助。
(I am also using .NET 4.0 and VS 2010.)
I created a function import returning a complex type, as explained at http://msdn.microsoft.com/en-us/library/bb896231.aspx. The function import and new complex type appear in my .edmx file and in the Designer.cs file. However, the function does not appear when I view the service in the browser, and when I add or update a service reference in the client project, the function does not appear there either - as is to be expected, given the first result.
Creating an imported function and using it seems conceptually very simple and straightforward, and one would think it would just work, as Microsoft's step-by-step instructions appear to suggest: http://msdn.microsoft.com/en-us/library/cc716672.aspx#Y798 (which article shows the SP returning entity types - I tried this also, and it doesn't work for me either).
This blog post shows the addition of a method to the DataService class, which Microsoft's instructions omit: http://www.codegain.com/articles/wcf/miscellaneous/how-to-use-stored-procedure-in-wcf-data-service.aspx I tried adding one method returning a list of entity types and another returning a list of complex types, and still had no success. I still could not access the functions, either directly via the browser or from the client application via a service reference.
Thanks in advance for any help with this.
发布评论
评论(1)
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
MS 最好在演练中添加注释,说明上述代码必须存在。 (显式启用每个操作可能比使用“*”更好。)
http://www.codegain.com/articles/wcf/miscellaneous/how-to-use-stored-procedure-in-wcf-data-service.aspx 显示该行代码。此外,当创建 WCF 数据服务时,代码中的某些内容已被注释掉。我们中的一些人喜欢删除我们不使用的、看起来无关紧要的注释掉的代码——有时这样做可能有点过早。
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
MS would do well to add a note to the walkthroughs stating that the above bit of code must be there. (It may be better to enable each operation explicitly than to use "*".)
http://www.codegain.com/articles/wcf/miscellaneous/how-to-use-stored-procedure-in-wcf-data-service.aspx shows that line of code. Also, something it is there in the code, commented out, when one creates the WCF Data Service. Some of us like to delete commented-out code that we aren't using and that seems irrelevant - perhaps doing so a bit prematurely, sometimes.