The "case" clause is supported in differents way for each dialects.If you want you can extend HQL functions registering your own. Try to find "iif" and look how we are managing it for various dialects.
2009/2/11 ccollie <[email protected]> > > I'm trying to write some portable lower level NH code and in one case > i need to do a conditional check. See below : > > <code> > > public String GetBoundsCondition(string latitudeColumnName, > string > longitudeColumnName, > string > swLatitudeColumnName, > string > swLongitudeColumnName, > string > neLatitudeColumnName, > string > neLongitudeColumnName) > { > StringBuilder sqlBuilder = new StringBuilder > ((longitudeColumnName.Length + latitudeColumnName.Length) * 2); > > > string condition = string.Format("({0} > {1})", > swLongitudeColumnName, neLongitudeColumnName); > string ifTrue = string.Format("(({0} < {1}) or ({2} > > {3}))", latitudeColumnName, swLongitudeColumnName, > > longitudeColumnName, neLongitudeColumnName); > > string ifFalse = string.Format("(({0} > {1}) and ({2} < > {3}))", > longitudeColumnName, swLongitudeColumnName, > longitudeColumnName, neLongitudeColumnName); > > // TODO: this needs to use CaseFragment for portability > ///CaseFragment fragment = this.dialect.CreateCaseFragment > (); > > > sqlBuilder > .Append("(") > .Append("case when ") > .Append(condition) > .Append(" then ") > .Append(ifTrue) > .Append(" else ") > .Append(ifFalse) > .Append(" end") > .Append(")") > .Append(" and (") > .Append(latitudeColumnName).Append(" > ").Append > (swLatitudeColumnName) > .Append(" and ") > .Append(latitudeColumnName).Append(" < ").Append > (neLatitudeColumnName) > .Append(")"); > > return sqlBuilder.ToString(); > } > </code> > > Notice the case statement. AFAIK, case is not universally supported. I > want to use CaseFragment, but i dont know how to get the same result > as above. > > > ccollie > > > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
