I am trying to use LINQ to Nhibernate to get a count on a table in my database. However, the code I am running is pulling back all of the records in the table versus running select count() from table.
Here's my code-
public int GetTotalCount(Func<T, bool> where) {
IQueryable<T> queryable = this._sessionManager.GetCurrentSession().Linq<T>().Where(where).AsQueryable();
return queryable.Count();
}
I also tried-
public int GetTotalCount(Func<T, bool> where)
{
IQueryable<T> queryable = this._sessionManager.GetCurrentSession().Linq<T>();
return queryable.Count(where);
}
Both pull back the entire dataset versus running a count. Any ideas?
Also, I'm using NHProf to profile it, so I can the query it is running, which is
select * from table