Ria 服务生成的代码在 Silverlight 代码中不可访问

发布于 2024-08-12 10:12:09 字数 763 浏览 3 评论 0原文

我有以下 Ria 服务定义:

namespace SilverlightTest.Web
{
    [EnableClientAccess()]
    public class ContactService : LinqToEntitiesDomainService<AdventureWorksEntities>
    {
        public IQueryable<Contact> GetContactSearch(string lastName)
        {
            ContactRepository rep = new ContactRepository();
            return rep.SearchByLastName(lastName);
        }
    }
}

当我编译解决方案时,我的 SilverlightTest 项目会创建 SilverlightTest.Web.g.cs 文件,并且当我查看它时会创建适当的 Context 对象。但是,当我尝试导入 SilverlightTest.Web 命名空间以访问上述服务的数据上下文类时,它表示找不到 Web 命名空间。

我可以看到我正在做的事情与网络上的许多示例之间的唯一区别是我的 AdventureWorksEntities 数据上下文位于单独的业务对象 dll 中。我尝试直接查询上下文,而不是使用我尝试执行的存储库模式,但它也不起作用。

有什么想法吗?是否可以让 Ria 服务访问单独的 DLL 来处理数据访问,还是必须位于同一个项目中?

I have the following Ria Service define:

namespace SilverlightTest.Web
{
    [EnableClientAccess()]
    public class ContactService : LinqToEntitiesDomainService<AdventureWorksEntities>
    {
        public IQueryable<Contact> GetContactSearch(string lastName)
        {
            ContactRepository rep = new ContactRepository();
            return rep.SearchByLastName(lastName);
        }
    }
}

When I compile the solution, my SilverlightTest project does create the SilverlightTest.Web.g.cs file and the appropriate Context objects are created when I look at it. However, when I attempt to import the SilverlightTest.Web namespace to access the Data Context class for the above service, it says it cannot find the Web namespace.

The only difference I can see between what I'm doing and many examples that are out there on the web is that my AdventureWorksEntities data context is located in a separate business object dll. I tried to query the context directly instead of using the Repository Pattern I'm attempting to do and it also isn't work working.

Any ideas? Is it possible to have Ria Services access a separate DLL handling data access or does it HAVE to be in the same project?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

非要怀念 2024-08-19 10:12:09

我之前已经能够将 Ria 服务放入一个单独的项目中,尽管我确实记得遇到了问题。不确定它到底是什么,但我会检查两件事:您的参考文献和您的 web.config(在托管网站中)。当您将 ria 服务添加到 Web 项目时,它会在幕后执行一些操作,以正确连接所有内容。

可以尝试暂时向您​​的 Web 项目添加一项服务,看看它添加了什么。

I've been able to put the Ria service in a separate project before, although I do remember having issues. Not sure exactly what it was, but I would check two things: your references and your web.config (in the hosting website). When you add a ria service to a web project it does some things behind the scenes that wire everything up correctly.

Could try adding a service to your web project temporarily and see what it adds.

别挽留 2024-08-19 10:12:09

Resharper 似乎无法识别 .gs 文件及其名称空间。如果您禁用 R# 或仅在没有智能感知的情况下进行编码,它就可以工作。

It seems that Resharper does not recognize the .gs files and their name spaces. If you disable R# or just code without intelisense it works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文