简体   繁体   中英

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). They are connected trough web services.

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.

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. That should quickly answer most of your questions in that regard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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