The
Login.cs
class shown in the following code snippet is the POCO, the class that NHibernate will use to map database rows. Each row in the database returned will be instantiated (also known as "newed up") in a new instance of the Login
class. The collection of rows will be returned as a generic IList
of Login
objects or an IList<Login>
.
Notice how each property in the class Login
maps directly to a property element in the hbm.xml
file. We really have five public properties on this object, Id
, FirstName
, LastName
, UserName
, and Password
. Each of these properties was defined earlier in the hbm.xml
file and mapped to a database field.
When NHibernate retrieves records from the database, it will create a new instance (also known as "new up") of a Login
object for each record it retrieves and use the public "setter" (set function) for each property to fill out the object.
public partial class Login { public Login() { } public virtual int Id { get; set; } public virtual string FirstName { get; set; } public virtual string LastName { get; set; } public virtual string UserName { get; set; } public virtual string Password { get; set; } }