Hi, Having trouble with an HQL query. If I remove the avg(..) from it it will return all of the empty weights, so the trouble is with the avg function. It seems clear in the Nhibernate docs that I can perform an aggregate function on the select item like this. Is my problem something to do with query.ToList not liking to return a list of one thing? I just get the "Could not execute query[SQL:SQL not available] message.
public List<T> HQLQuery<T>(string HQL) //in UnitOfWork
{
var query = session.CreateQuery(HQL);
return query.List<T>().ToList<T>();
}
public static float estimateTruckEmptyWeight(int vehicleID)
{
UnitOfWork uow = new UnitOfWork();
List<float> results = uow.HQLQuery<float>("select avg(ev.EmptyWeight) from FieldSystemCore.Domain.EmptyVehicle ev where ev.Vehicle.ID = '" + vehicleID + "'");
return results[0];
}