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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to