具有 SubSonic 实体的 MVC3 应用程序?
我开始编写一个执行基本搜索的 MVC3 应用程序。我创建了一个 WCF 服务,其中公开了 GetDataAsDataSet() 方法,并在我的 MVC 项目中使用该服务。目前我认为这个方法是最简单的,因为它只返回一个数据集。我确实想添加 GetDataAsEntity() ,它稍后(或现在?)返回通过 SubSonic 生成的实际数据库实体类型...
到目前为止,我知道如果我的服务需要在 MVC3 项目的 Models 文件夹中包含这些实体返回这些实体的类型。然而这些都需要以“Models”结尾吗?
SubSonic 还创建 [entityname]Controller.cs 文件 - 是否可以将这些文件放置在控制器文件夹中并将实际实体类重命名为 [entityname]Models.cs ?
我想我的 Models 文件夹中需要这些,因为我想利用 WCF 服务,我最终将返回一个实体实体类型。
我可以轻松地让第一个解决方案起作用(返回一个简单的数据表),这是第二个选项,我需要一些帮助 - 从 WCF 服务传回复杂类型并在我的 MVC3 应用程序中使用它。
谢谢。
I'm starting to write an MVC3 application that performs a basic search. I've created a WCF service with a GetDataAsDataSet() method exposed and consume the service in my MVC project. For now this method I think is the simplest, as it merely returns a data set. I do want to add GetDataAsEntity() which returns the actual database entity type generated through SubSonic later (or now?)...
So far, I know that I need to have these entities in the Models folder of my MVC3 project if my service is returning a type of these entities. However do these all need to end with "Models"?
SubSonic also creates [entityname]Controller.cs files - can these be placed in the controllers folders and rename the actual entity classes to [entityname]Models.cs ?
I'm thinking I need these in my Models folder, as I want to make use of the WCF Service, which I will ultimately have returning an entity entity type.
I can easily get the first solution to work (returning a simple datatable), it's the second option, that I need some assistance with - passing back the complex type from the WCF Service and consuming that in my MVC3 application.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要自定义 SubSonic T4 文件并使所有生成的类都具有
[DataContract]
和[DataMember]
属性,然后 WCF 应该能够直接序列化从 SubSonic 读取的记录。I think you would need to customize your SubSonic T4 files and make all the generated classes have the
[DataContract]
and[DataMember]
attributes, then WCF should be able to directly serialize the records read from SubSonic.