Reputation: 546
i want to get data from sql server database in asp.net using NHibernate. what are the major steps i need to write for nhibernating. i have declared my class and its properties.
public class Student
{
private int id;
private string name;
private DateTime dateofbirth;
private string address;
public int Id
{
get { return id; }
private set { id = value; }
}
public string Name
{
get { return name; }
private set { name = value; }
}
public DateTime DateOfBirth
{
get { return dateofbirth; }
private set { dateofbirth = value; }
}
public string Address
{
get { return address; }
private set { address = value; }
}
}
Upvotes: 0
Views: 167
Reputation: 72930
You need to firstly make all of those properties virtual
so that NHibernate can proxy them. Then you need to work out how to map the class to the database. You can do this with XML mapping files, or something like Fluent NHibernate - I'd recommend the latter.
And obviously you'll need a matching database - there are ways to generate a script for this using NHibernate as well if you need this. But from your question I'm assuming the database is pre-existing.
Upvotes: 4