代码生成 - 通过引用数据库表生成 DTO。
我正在使用 NHibernate。我需要生成 DTO 来携带数据。我不想用手做。因此,我正在寻找捷径和工具来帮助我。我希望找到一个简单的工具来生成镜像数据库表的对象。这些对象的属性将具有与数据库表相同的名称和等效类型。
I'm working with NHibernate. I need to generate DTOs to carry data around. I don't want to do it by hand. Hence I'm looking for shortcuts and tools to help me. I was hoping to find a simple tool that generates a objects which mirror the database tables. The properties of these objects would have same name and equivalent types as of database tables.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看数据库并创建类型的工具称为 ORM(对象关系映射器)。有免费的和商业的:Entity Framework 和 LLBLGEN 浮现在脑海中。
如果您已经有了自己的类型,则可以使用 AutoMapper 转换为 DTO:
A tool that looks at your database and creates types is called an ORM (Object Relational Mapper). There are both free and commercial ones available: Entity Framework and LLBLGEN spring to mind.
If you already have your types, you could use AutoMapper to convert to DTOs:
Visual Nhibernate 可以从数据库架构生成域对象。然后您可以修改这些对象并最终得到您需要的 DTO。一旦您拥有这两种对象类型,您就可以遵循 Mitch 的建议并使用 EmitMapper 或 AutoMapper 等工具自动将 Domain 对象映射到 DTOS。
Visual Nhibernate can generate domain objects from your database schema. You could then modify these objects and end up with the DTOs you need. Once you have both object types you can follow Mitch's advice and use a tool like EmitMapper or AutoMapper to automatically map Domain objects to DTOS.
在观看 http://summerofnhibernate.com/ 的一场会议时找到了我正在寻找的内容,特别是会议 08:有效数据库驱动建模技术。
他使用的工具名为 MyGeneration,它通过查看数据库表来构建 DTO。
Found what I was looking for while watching one of the sessions of http://summerofnhibernate.com/ specifically Session 08: Effective Techniques for Database-Driven Modeling.
The tool he is using is called MyGeneration which builds DTOs by looking at database tables.