Hibernate version: 2.0.0 Alpha 2
Name and version of the database you are using: SQL Server 2005
How do you retrieve the column alias for a computed (formula) property when using Expression.Sql?
For example, I have a property generated using:
Code:
<property name="BiographyLocalised" type="System.String" not-null="true"
formula="CASE WHEN :LanguageFilter.IsInitialised = 1 THEN IsNull((select WT.Name from Translation WT where WT.EntityID = ContactID and WT.TranslationTypeID = :LanguageFilter.ContactBiographyTranslationTypeID and WT.LanguageID = :LanguageFilter.LanguageID), Biography) ELSE Biography END"
/>
I want to run a Contains() expression on this property, for which I must use Expression.SQL. How can I get NHibernate to replace the column name with the generated SQL alias?
Code:
c.Add(Expression.Sql("contains({alias}.BiographyLocalised, ?)", query.ToSafeContainsQuery(), NHibernateUtil.String))
Does not work because BiographyLocalised is a formula column and does not exist in the table represented by {alias}.