Hi!
I'd like to know how to select just a few columns instead of all by using a criteria query.
Here is my current code:
Code:
public ICollection<Geo> GetGeo(string city, int? plc, int? areaCode, string federalState)
{
using (ISession session = NHibernateHelper.OpenSession())
{
ICriteria criteria = session.CreateCriteria(typeof(Geo));
if (city.Length != 0)
criteria.Add(Expression.Sql("City LIKE ?", city + "%", NHibernateUtil.String));
if (plc.HasValue)
criteria.Add(Expression.Eq("Plc", plc));
if (areaCode.HasValue)
criteria.Add(Expression.Eq("AreaCode", areaCode));
if (federalState != null)
criteria.Add(Expression.Eq("FederalState", federalState));
return criteria.List<Geo>();
}
}
But up to now, I get all columns of the Geo table. How can I now select just city, plc, areaCode and federalState?
Regards, Joe