是否可以使用 ASP.NET 动态数据和 SubSonic 3?
是否可以将 ASP.NET 动态数据与 SubSonic 3 一起使用来代替 Linq to SQL 类或实体框架?如果您使用 SubSonic 生成的上下文类,MetaModel.RegisterContext() 会引发异常。我想我记得在 SubSonic 3 发布之前遇到过 SubSonic/Dynamic Data 示例,但现在找不到了。有人能够让它发挥作用吗?
Is it possible to use ASP.NET Dynamic Data with SubSonic 3 in-place of Linq to SQL classes or the Entity Framework? MetaModel.RegisterContext() throws an exception if you use the context class that SubSonic generates. I thought I remembered coming across a SubSonic/Dynamic Data example back before SubSonic 3 was released but I can't find it now. Has anyone been able to get this to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一些工作后,我昨晚刚刚在 Visual Studio 2010 中使用我的 SQLite 数据库让 Subsonic 3.0.0.4 ActiveRecord 工作起来,为了您的利益,我尝试记录此处所采取的步骤。
首先添加一个新项目 ->将 WCF 数据服务添加到您用来托管 Web 应用程序/Web 服务的项目,然后对其进行类似于下面的 PinsDataService.svc.cs 的修改:
此时,如果您匹配所有数据库,您的动态数据服务可能会正常工作命名约定很完美,但我没有那样的运气。在我的 ActiveRecord.tt 模板中,我必须在公共部分类声明之前添加以下两行:
然后添加对 System.Data 和 System.Data 的引用.Services.Client,然后在顶部包含 使用 System.Data.Services 和 使用 System.Data.Services.Common 的 using 语句ActiveRecord.tt 模板。
下一步是使用这篇博客文章中的 IUpdateable 部分类实现 http://blogs.msdn.com/aconrad/archive/2008/12/05/developing-an-astoria-data-provider-for-subsonic.aspx 并更改
public 分部类 dbPINSDB : IUpdatable
以匹配我在 Settings.ttinclude 中声明的亚音速 DatabaseName然后在我开始的单独客户端应用程序/库中使用数据从我的客户端应用程序向 PinsDataService.svc 添加一个名为 PinsDataService 的“服务引用”,然后前往城镇:
注意我如何执行仅返回 1 个对象的Where 查询,但我放入了 Take(1),然后放入了 ElementAt(0 )因为当我尝试使用 SingleOrDefault() 或 First() 时,我不断收到错误
希望这有帮助 - 另外,我已经意识到 dbPINSDB 是一个真的坏我的亚音速数据库的名称;)
I just got Subsonic 3.0.0.4 ActiveRecord working last night in Visual Studio 2010 with my SQLite database after a little bit of work and I've tried to document the steps taken here for your benefit.
Start by adding a New Item -> WCF Data Service to the project you're using to host your webapp/webservices then modify it similar to my PinsDataService.svc.cs below:
At this point your Dynamic Data Service would probably be working if you matched all the database naming conventions perfectly but I didn't have that kind of luck. In my ActiveRecord.tt template I had to prepend the following two lines before the public partial class declarations:
I then added references to System.Data and System.Data.Services.Client followed by the inclusion of using statements for using System.Data.Services and using System.Data.Services.Common at the top of the ActiveRecord.tt template.
The next step was to use the IUpdateable partial class implementation from this blog post http://blogs.msdn.com/aconrad/archive/2008/12/05/developing-an-astoria-data-provider-for-subsonic.aspx and change the
public partial class dbPINSDB : IUpdatable
to match my subsonic DatabaseName declared in Settings.ttincludeThen to consume the data in a separate client app/library I started by adding a 'Service Reference' named PinsDataService to the PinsDataService.svc from my client app and went to town:
Note how I'm doing a Where query that returns only 1 object but I threw in the Take(1) and then ElementAt(0) because I kept getting errors when I tried to use SingleOrDefault() or First()
Hope this helps--also, I'm already aware that dbPINSDB is a really bad name for my Subsonic Database ;)