/// <summary> /// Returns to nhibernate the type of the parameters. /// I need only one operator. /// </summary> /// <param name="criteria"></param> /// <param name="criteriaQuery"></param> /// <returns></returns> public override NHibernate.Engine.TypedValue[] GetTypedValues( NHibernate.ICriteria criteria, NHibernate.Expressions.ICriteriaQuery criteriaQuery) { return(new TypedValue[] { new TypedValue(GetITypeFromCLRType(mValueToCompareTo.GetType()), mValueToCompareTo) }); }
/// <summary> /// This is the real core function that build the fragment of sql needed /// to build the criteria /// </summary> /// <param name="criteria"></param> /// <param name="criteriaQuery"></param> /// <param name="context"></param> /// <returns></returns> public override NHibernate.SqlCommand.SqlString ToSqlString( NHibernate.ICriteria criteria, NHibernate.Expressions.ICriteriaQuery criteriaQuery, IDictionary <string, IFilter> enabledFilters) { //retrieve with projection the real name of the property. String[] PropertyColumn = criteriaQuery.GetColumnsUsingProjection( criteria, (String)mSqlFunctionParameter[mPropertyNamePosition]); NHibernate.Dialect.Dialect dialect = criteriaQuery.Factory.Dialect; mSqlFunctionParameter[mPropertyNamePosition] = PropertyColumn[0]; if (!dialect.Functions.ContainsKey(mFunction)) { //throw new ApplicationException("Current dialect does not support " + mFunction + " function"); //Todo for now try to set the function but without the dialect. return(CreateQueryString( BuildUnknownExpression(mFunction, mSqlFunctionParameter))); } ISQLFunction func = (ISQLFunction)dialect.Functions[mFunction]; String functionResolved = func.Render(mSqlFunctionParameter, criteriaQuery.Factory); //Now we have the cast operation required. return(CreateQueryString(functionResolved)); }