Hi all,
I'm using this hql query for my filters. Query perfectly working except width (string) part.
Here is the query,
public IList<ColorGroup> GetDistinctColorGroups(int typeID, int finishID, string width)
{
string queryStr = "Select distinct c from ColorGroup c inner join c.Products p " +
"where p.ShowOnline = 1 ";
if (typeID > 0)
queryStr += " and p.ProductType.ID = " + typeID;
if (finishID > 0)
queryStr += " and p.FinishGroup.ID = " + finishID;
if (width != "")
queryStr += " and p.Size.Width = " + width;
IList<ColorGroup> colors = NHibernateSession.CreateQuery(queryStr).List<ColorGroup>();
return colors;
}
ProductType and Size have same mappings and relations.
This is the error;
NHibernate.QueryException: illegal syntax near collection: Size [Select distinct c from .Domain.ColorGroup c inner join c.Products p where p.ShowOnline = 1 and p.ProductType.ID = 1 and p.FinishGroup.ID = 5 and p.Size.Width = 4]
Any ideas ?
edit:
Btw in this project I used this linq query which is really simmilar hql one. So I don't think it's a misstype or more fundamentally error..
colorOfSerie = (from p in products where p.Size.Width.Equals(width) select p.ColorGroup).Distinct().ToList<ColorGroup>();