Hi. I'm a newbie in the great world of NHibernate. I'm using version 2.0.1.GA. Here's my question. I have a table Cars
with column Manufacturer(nvarchar(50))
and a primary key ID(int)
. My .NET class is:
public class Car
{
public virtual int ID { get; set; }
public virtual string Manufacturer { get; set; }
}
Now if I want to retrieve all cars made by Mercedes I have to type this:
using (var session = OpenSession())
{
var cars = session
.CreateCriteria(typeof(Car))
.Add(Restrictions.Like("Manufacturer", "Mercedes"))
.List();
// ...
}
I don't like the fact that I need to specify the property name as a string :( Is it possible to have something more refactor friendly probably (it's only a suggestion)?
var ms = session
.CreateCriteria<Car>()
.Add(c => c.Manufacturer, Restrictions.Like("Mercedes")
.List();
Anything like thins in the current version (2.0.1.GA) or in a future version?