[ACCEPTED]-Executing Sql statements with Fluent NHibernate-nhibernate

Accepted answer
Score: 36

As already mentioned, this is not a Fluent 3 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:

    return Convert.ToInt32(result);

You 2 will want to investigate the ISQLQuery interface, depending 1 on your needs.

More Related questions