Basically I want to be able to do this:
session.ExecuteSql("...");
I don't need it to map to any entities or return any values. Any suggestions?
As already mentioned, this is not a Fluent NHibernate issue but here is an example:
public int GetSqlCount<T>(Session session, string table)
{
var sql = String.Format("SELECT Count(*) FROM {0}", table);
var query = session.CreateSQLQuery(sql);
var result = query.UniqueResult();
// Could also use this if only updating values:
//query.ExecuteUpdate();
return Convert.ToInt32(result);
}
You will want to investigate the ISQLQuery interface, depending on your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With