简体   繁体   English

设计类结构来映射关系数据库的基本规则是什么?

[英]What are the basic rules for designing class structure to map relational database?

A WPF application should be a visualizer front-end for a ERP database (in fact only small part of it). WPF应用程序应该是ERP数据库的可视化器前端(实际上只是其中的一小部分)。 They are connected trough web services. 它们通过Web服务连接。

What are main rules for designing a data model class structure for mapping database tables? 设计用于映射数据库表的数据模型类结构的主要规则是什么? For example, should it be a one big flat class with lots of members, or lots of classes representing different tables in database? 例如,它应该是一个包含大量成员的大型平面类,还是代表数据库中不同表的许多类?

If at all possible, use a standard Object/Relational Mapper (ORM) such as NHibernate, LINQ to SQL or the Entity Framework. 如果可能的话,使用标准的对象/关系映射器(ORM),如NHibernate,LINQ to SQL或实体框架。

They typically have wizards that can generate the object model based on the database schema. 它们通常具有可以基于数据库模式生成对象模型的向导。 The default approach seems consistently to be to create a class per table, which makes a lot of sense. 默认方法似乎始终是为每个表创建一个类,这很有意义。

If your database is proprietary and you can't work with a standard ORM, I'd still recommend that you take one of them for a spin to understand how they model relational databases. 如果您的数据库是专有的并且您无法使用标准ORM,我仍然建议您将其中一个用于旋转,以了解它们如何为关系数据库建模。 That should quickly answer most of your questions in that regard. 在这方面,这应该很快回答你的大部分问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM