public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary <string, IFilter> enabledFilters) { SqlString[] columnNames = CriterionUtil.GetColumnNames(_lhsPropertyName, _lhsProjection, criteriaQuery, criteria, enabledFilters); SqlString[] otherColumnNames = CriterionUtil.GetColumnNames(_rhsPropertyName, _rhsProjection, criteriaQuery, criteria, enabledFilters); SqlStringBuilder sb = new SqlStringBuilder(); if (columnNames.Length > 1) { sb.Add(StringHelper.OpenParen); } bool first = true; foreach (SqlString sqlString in StringHelper.Add(columnNames, Op, otherColumnNames)) { if (first == false) { sb.Add(" and "); } first = false; sb.Add(sqlString); } if (columnNames.Length > 1) { sb.Add(StringHelper.ClosedParen); } return(sb.ToSqlString()); }
/// <summary> /// /// </summary> /// <param name="factory"></param> /// <param name="persistentClass"></param> /// <param name="alias"></param> /// <returns></returns> public override SqlString ToSqlString(ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses) { SqlStringBuilder sqlBuilder = new SqlStringBuilder(); string[] columnNames = AbstractCriterion.GetColumns(factory, persistentClass, _lhsPropertyName, alias, aliasClasses); string[] otherColumnNames = AbstractCriterion.GetColumns(factory, persistentClass, _rhsPropertyName, alias, aliasClasses); string result = string.Join( " and ", StringHelper.Add(columnNames, Op, otherColumnNames) ); if (columnNames.Length > 1) { result = StringHelper.OpenParen + result + StringHelper.ClosedParen; } return(new SqlString(result)); //TODO: get SQL rendering out of this package! }