Book Image

Learning NHibernate 4

Book Image

Learning NHibernate 4

Overview of this book

Table of Contents (18 chapters)
Learning NHibernate 4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Components


We have seen components in Chapter 3, Let's Tell NHibernate About Our Database. We had seen that ResidentialAddress property on Employee class can be mapped as a component or as a one-to-one relation. When it is mapped as a component, all properties on the Address class are assumed to be present in the Employee table, while you get the freedom to use a separate class to represent an address. With one-to-one mapping, the Address class is mapped to its own table.

It is possible that the database that you are working with has modeled such instances in one of the two ways. If you want to model a domain concept using its own class, but state information in that class is not kept in its own table, then you can use components.

Since we covered components in Chapter 3, Let's Tell NHibernate About Our Database in detail; we would not discuss them in any more detail here. Just remember that components exist, and use them whenever you can.