How do I delete an object without fetching it from the db first?
In another ORM, I can do this:
session.Delete(1); // 1 = PK
Add the following class to your project:
public static class SessionHelper
{
public static void Delete(this ISession session, object id)
{
var queryString = string.Format("delete {0} where id = :id",
typeof(TEntity));
session.CreateQuery(queryString)
.SetParameter("id", id)
.ExecuteUpdate();
}
}
You can now use session.Delete
.