Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10283/NHibernate/Expression Modified Files: AbstractCriterion.cs AndExpression.cs BetweenExpression.cs Conjunction.cs Disjunction.cs EqExpression.cs EqPropertyExpression.cs Example.cs Expression.cs GeExpression.cs GtExpression.cs ICriterion.cs InExpression.cs InsensitiveLikeExpression.cs Junction.cs LeExpression.cs LePropertyExpression.cs LikeExpression.cs LogicalExpression.cs LtExpression.cs LtPropertyExpression.cs MatchMode.cs NotExpression.cs NotNullExpression.cs NullExpression.cs Order.cs OrExpression.cs PropertyExpression.cs SimpleExpression.cs SQLExpression.cs Log Message: Fixed up the QBE portion of NHibernate.Expression. Index: InsensitiveLikeExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/InsensitiveLikeExpression.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** InsensitiveLikeExpression.cs 31 Dec 2004 17:54:19 -0000 1.4 --- InsensitiveLikeExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 *************** *** 1,2 **** --- 1,3 ---- + using System.Collections; using NHibernate.Dialect; using NHibernate.Engine; *************** *** 8,29 **** { /// <summary> ! /// Summary description for InsensitiveLikeExpression. ! /// /// </summary> //TODO:H2.0.3 renamed this to ILikeExpression ! public class InsensitiveLikeExpression : Expression { ! private readonly string propertyName; ! private readonly object expressionValue; /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="expressionValue"></param> ! internal InsensitiveLikeExpression( string propertyName, object expressionValue ) { ! this.propertyName = propertyName; ! this.expressionValue = expressionValue; } --- 9,31 ---- { /// <summary> ! /// An <see cref="ICriterion"/> that represents an "like" constraint ! /// that is <b>not</b> case sensitive. /// </summary> //TODO:H2.0.3 renamed this to ILikeExpression ! public class InsensitiveLikeExpression : AbstractCriterion { ! private readonly string _propertyName; ! private readonly object _value; /// <summary> ! /// Initialize a new instance of the <see cref="InsensitiveLikeExpression" /> ! /// class for a named Property and its value. /// </summary> ! /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="value">The value for the Property.</param> ! internal InsensitiveLikeExpression( string propertyName, object value ) { ! _propertyName = propertyName; ! _value = value; } *************** *** 35,46 **** /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( propertyName ); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); ! string[ ] paramColumnNames = GetColumns( factory, persistentClass, propertyName, null ); Parameter[ ] parameters = Parameter.GenerateParameters( factory, alias, paramColumnNames, propertyType ); --- 37,49 ---- /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( _propertyName ); ! string[ ] columnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName, alias, aliasClasses ); ! // don't need to worry about aliasing or aliasClassing for parameter column names ! string[ ] paramColumnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName ); Parameter[ ] parameters = Parameter.GenerateParameters( factory, alias, paramColumnNames, propertyType ); *************** *** 71,77 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { ! return new TypedValue[ ] {Expression.GetTypedValue( sessionFactory, persistentClass, propertyName, expressionValue.ToString().ToLower() )}; } --- 74,80 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { ! return new TypedValue[ ] { AbstractCriterion.GetTypedValue( sessionFactory, persistentClass, _propertyName, _value.ToString().ToLower(), aliasClasses )}; } *************** *** 79,83 **** public override string ToString() { ! return propertyName + " ilike " + expressionValue; } } --- 82,86 ---- public override string ToString() { ! return _propertyName + " ilike " + _value; } } Index: NotNullExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/NotNullExpression.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** NotNullExpression.cs 31 Dec 2004 17:55:35 -0000 1.6 --- NotNullExpression.cs 17 Apr 2005 17:16:05 -0000 1.7 *************** *** 1,25 **** using NHibernate.Engine; - using NHibernate.Persister; using NHibernate.SqlCommand; - using NHibernate.Type; namespace NHibernate.Expression { /// <summary> ! /// Constrains a property to be non-null /// </summary> ! public class NotNullExpression : Expression { ! private readonly string propertyName; private static readonly TypedValue[ ] NoValues = new TypedValue[0]; /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> internal NotNullExpression( string propertyName ) { ! this.propertyName = propertyName; } --- 1,26 ---- + using System; + using System.Collections; using NHibernate.Engine; using NHibernate.SqlCommand; namespace NHibernate.Expression { /// <summary> ! /// An <see cref="ICriterion"/> that represents "not null" constraint. /// </summary> ! public class NotNullExpression : AbstractCriterion { ! private readonly string _propertyName; private static readonly TypedValue[ ] NoValues = new TypedValue[0]; /// <summary> ! /// Initialize a new instance of the <see cref="NotNullExpression" /> class for a named ! /// Property that should not be null. /// </summary> ! /// <param name="propertyName">The name of the Property in the class.</param> internal NotNullExpression( string propertyName ) { ! _propertyName = propertyName; } *************** *** 31,41 **** /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( propertyName ); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); --- 32,41 ---- /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! string[ ] columnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName, alias, aliasClasses ); *************** *** 46,49 **** --- 46,50 ---- if( andNeeded ) { + // TODO: h2.1 SYNCH - why did hibernate change this to " or " sqlBuilder.Add( " AND " ); } *************** *** 64,68 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { return NoValues; --- 65,69 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { return NoValues; *************** *** 72,76 **** public override string ToString() { ! return propertyName + " is not null"; } } --- 73,77 ---- public override string ToString() { ! return _propertyName + " is not null"; } } Index: SimpleExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/SimpleExpression.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SimpleExpression.cs 31 Dec 2004 17:55:48 -0000 1.6 --- SimpleExpression.cs 17 Apr 2005 17:16:05 -0000 1.7 *************** *** 1,2 **** --- 1,3 ---- + using System.Collections; using NHibernate.Engine; using NHibernate.Persister; *************** *** 7,29 **** { /// <summary> ! /// The base class for an Expression that compares a single Property /// to a value. /// </summary> ! public abstract class SimpleExpression : Expression { ! private readonly string propertyName; ! private readonly object expressionValue; /// <summary> ! /// Initialize a new instance of the SimpleExpression class for a named /// Property and its value. /// </summary> /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="expressionValue">The value for the Property.</param> ! internal SimpleExpression( string propertyName, object expressionValue ) { ! this.propertyName = propertyName; ! this.expressionValue = expressionValue; } --- 8,30 ---- { /// <summary> ! /// The base class for an <see cref="ICriterion"/> that compares a single Property /// to a value. /// </summary> ! public abstract class SimpleExpression : AbstractCriterion { ! private readonly string _propertyName; ! private readonly object _value; /// <summary> ! /// Initialize a new instance of the <see cref="SimpleExpression" /> class for a named /// Property and its value. /// </summary> /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="value">The value for the Property.</param> ! internal SimpleExpression( string propertyName, object value ) { ! _propertyName = propertyName; ! _value = value; } *************** *** 34,38 **** public string PropertyName { ! get { return propertyName; } } --- 35,39 ---- public string PropertyName { ! get { return _propertyName; } } *************** *** 43,47 **** public object Value { ! get { return expressionValue; } } --- 44,48 ---- public object Value { ! get { return _value; } } *************** *** 53,64 **** /// <param name="alias">The alias to use for the table.</param> /// <returns>A SqlString that contains a valid Sql fragment.</returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( propertyName ); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); ! string[ ] paramColumnNames = GetColumns( factory, persistentClass, propertyName, null ); Parameter[ ] parameters = Parameter.GenerateParameters( factory, alias, paramColumnNames, propertyType ); --- 54,66 ---- /// <param name="alias">The alias to use for the table.</param> /// <returns>A SqlString that contains a valid Sql fragment.</returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( _propertyName ); ! string[ ] columnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName, alias, aliasClasses ); ! // don't need to worry about aliasing or aliasClassing for parameter column names ! string[ ] paramColumnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName ); Parameter[ ] parameters = Parameter.GenerateParameters( factory, alias, paramColumnNames, propertyType ); *************** *** 86,92 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { ! return new TypedValue[ ] {GetTypedValue( sessionFactory, persistentClass, propertyName, expressionValue )}; } --- 88,94 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { ! return new TypedValue[ ] {AbstractCriterion.GetTypedValue( sessionFactory, persistentClass, _propertyName, _value, aliasClasses )}; } *************** *** 94,102 **** public override string ToString() { ! return propertyName + Op + expressionValue; } ! /// <summary></summary> ! protected abstract string Op { get; } //protected ??? } } \ No newline at end of file --- 96,107 ---- public override string ToString() { ! return _propertyName + Op + _value; } ! /// <summary> ! /// Get the Sql operator to use for the specific ! /// subclass of <see cref="SimpleExpression"/>. ! /// </summary> ! protected abstract string Op { get; } } } \ No newline at end of file Index: MatchMode.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/MatchMode.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MatchMode.cs 28 Mar 2005 12:45:58 -0000 1.1 --- MatchMode.cs 17 Apr 2005 17:16:05 -0000 1.2 *************** *** 4,7 **** --- 4,8 ---- namespace NHibernate.Expression { + // TODO: find where this is used and test/fix it up /// <summary> /// Represents an strategy for matching strings using "like". *************** *** 9,15 **** public abstract class MatchMode { ! private int intCode; ! private string name; ! private static Hashtable INSTANCES = new Hashtable(); /// <summary> --- 10,16 ---- public abstract class MatchMode { ! private int _intCode; ! private string _name; ! private static Hashtable Instances = new Hashtable(); /// <summary> *************** *** 20,25 **** protected MatchMode(int intCode, string name) { ! this.intCode = intCode; ! this.name = name; } --- 21,26 ---- protected MatchMode(int intCode, string name) { ! this._intCode = intCode; ! this._name = name; } *************** *** 30,34 **** public override string ToString() { ! return name; } --- 31,35 ---- public override string ToString() { ! return _name; } *************** *** 38,52 **** public abstract string ToMatchString(string pattern); ! private Object ReadResolve() ! { ! return INSTANCES[intCode]; ! } static MatchMode() { ! INSTANCES.Add(EXACT.intCode, EXACT); ! INSTANCES.Add(START.intCode, START); ! INSTANCES.Add(END.intCode, END); ! INSTANCES.Add(ANYWHERE.intCode, ANYWHERE); } --- 39,55 ---- public abstract string ToMatchString(string pattern); ! // TODO: need to fix up so serialization/deserialization ! // preserves the singleton ! // private Object ReadResolve() ! // { ! // return INSTANCES[intCode]; ! // } static MatchMode() { ! Instances.Add( Exact._intCode, Exact ); ! Instances.Add( Start._intCode, Start ); ! Instances.Add( End._intCode, End ); ! Instances.Add( Anywhere._intCode, Anywhere ); } *************** *** 54,76 **** /// Match the entire string to the pattern /// </summary> ! public static readonly MatchMode EXACT = new ExactMatchMode(); /// <summary> /// Match the start of the string to the pattern /// </summary> ! public static readonly MatchMode START = new StartMatchMode(); /// <summary> /// Match the end of the string to the pattern /// </summary> ! public static readonly MatchMode END = new EndMatchMode(); /// <summary> /// Match the pattern anywhere in the string /// </summary> ! public static readonly MatchMode ANYWHERE = new AnywhereMatchMode(); private class ExactMatchMode : MatchMode { ! public ExactMatchMode():base(0, "EXACT") { - } --- 57,81 ---- /// Match the entire string to the pattern /// </summary> ! public static readonly MatchMode Exact = new ExactMatchMode(); ! /// <summary> /// Match the start of the string to the pattern /// </summary> ! public static readonly MatchMode Start = new StartMatchMode(); ! /// <summary> /// Match the end of the string to the pattern /// </summary> ! public static readonly MatchMode End = new EndMatchMode(); ! /// <summary> /// Match the pattern anywhere in the string /// </summary> ! public static readonly MatchMode Anywhere = new AnywhereMatchMode(); private class ExactMatchMode : MatchMode { ! public ExactMatchMode() : base( 0, "EXACT" ) { } *************** *** 83,90 **** private class StartMatchMode : MatchMode { ! public StartMatchMode() : base(1, "START") { ! ! } public override string ToMatchString(string pattern) --- 88,94 ---- private class StartMatchMode : MatchMode { ! public StartMatchMode() : base( 1, "START" ) { ! } public override string ToMatchString(string pattern) *************** *** 96,100 **** private class EndMatchMode : MatchMode { ! public EndMatchMode() : base(2, "END") { } --- 100,104 ---- private class EndMatchMode : MatchMode { ! public EndMatchMode() : base( 2, "END" ) { } *************** *** 109,114 **** private class AnywhereMatchMode : MatchMode { ! public AnywhereMatchMode() : base(3, "ANYWHERE") ! { } --- 113,118 ---- private class AnywhereMatchMode : MatchMode { ! public AnywhereMatchMode() : base( 3, "ANYWHERE" ) ! { } *************** *** 121,123 **** } ! } --- 125,127 ---- } ! } \ No newline at end of file Index: PropertyExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/PropertyExpression.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PropertyExpression.cs 31 Dec 2004 17:55:48 -0000 1.2 --- PropertyExpression.cs 17 Apr 2005 17:16:05 -0000 1.3 *************** *** 1,2 **** --- 1,3 ---- + using System.Collections; using NHibernate.Engine; using NHibernate.SqlCommand; *************** *** 5,26 **** { /// <summary> ! /// Superclass for comparisons between two properties (with SQL binary operators) /// </summary> ! public abstract class PropertyExpression : Expression { ! private string propertyName; ! private string otherPropertyName; private static TypedValue[ ] NoTypedValues = new TypedValue[0]; /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="otherPropertyName"></param> ! protected PropertyExpression( string propertyName, string otherPropertyName ) { ! this.propertyName = propertyName; ! this.otherPropertyName = otherPropertyName; } --- 6,29 ---- { /// <summary> ! /// Superclass for an <see cref="ICriterion"/> that represents a ! /// constraint between two properties (with SQL binary operators). /// </summary> ! public abstract class PropertyExpression : AbstractCriterion { ! private string _lhsPropertyName; ! private string _rhsPropertyName; private static TypedValue[ ] NoTypedValues = new TypedValue[0]; /// <summary> ! /// Initialize a new instance of the <see cref="PropertyExpression" /> class ! /// that compares two mapped properties. /// </summary> ! /// <param name="lhsPropertyName">The name of the Property to use as the left hand side.</param> ! /// <param name="rhsPropertyName">The name of the Property to use as the right hand side.</param> ! protected PropertyExpression(string lhsPropertyName, string rhsPropertyName) { ! _lhsPropertyName = lhsPropertyName; ! _rhsPropertyName = rhsPropertyName; } *************** *** 32,41 **** /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); ! string[ ] otherColumnNames = GetColumns( factory, persistentClass, otherPropertyName, alias ); bool andNeeded = false; --- 35,44 ---- /// <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 ); bool andNeeded = false; *************** *** 63,67 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { return NoTypedValues; --- 66,70 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { return NoTypedValues; *************** *** 71,78 **** public override string ToString() { ! return propertyName + Op + otherPropertyName; } ! /// <summary></summary> protected abstract string Op { get; } } --- 74,83 ---- public override string ToString() { ! return _lhsPropertyName + Op + _rhsPropertyName; } ! /// <summary> ! /// Get the Sql operator to use for the property expression. ! /// </summary> protected abstract string Op { get; } } Index: Order.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/Order.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Order.cs 31 Dec 2004 17:55:35 -0000 1.5 --- Order.cs 17 Apr 2005 17:16:05 -0000 1.6 *************** *** 1,2 **** --- 1,3 ---- + using System.Collections; using NHibernate.Engine; *************** *** 4,13 **** { /// <summary> ! /// Represents an order imposed upon a ICriteria result set /// </summary> public class Order { ! private bool ascending; ! private string propertyName; /// <summary> --- 5,15 ---- { /// <summary> ! /// Represents an order imposed upon a <see cref="ICriteria"/> ! /// result set. /// </summary> public class Order { ! private bool _ascending; ! private string _propertyName; /// <summary> *************** *** 18,23 **** protected Order( string propertyName, bool ascending ) { ! this.propertyName = propertyName; ! this.ascending = ascending; } --- 20,25 ---- protected Order( string propertyName, bool ascending ) { ! _propertyName = propertyName; ! _ascending = ascending; } *************** *** 32,41 **** public string ToStringForSql( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, string alias ) { ! string[ ] columns = Expression.GetColumns( sessionFactory, persistentClass, propertyName, alias ); if( columns.Length != 1 ) { ! throw new HibernateException( "Cannot order by multi-column property: " + propertyName ); } ! return columns[ 0 ] + ( ascending ? " asc" : " desc" ); } --- 34,43 ---- public string ToStringForSql( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, string alias ) { ! string[ ] columns = AbstractCriterion.GetColumns( sessionFactory, persistentClass, _propertyName, alias, emptyMap ); if( columns.Length != 1 ) { ! throw new HibernateException( "Cannot order by multi-column property: " + _propertyName ); } ! return columns[ 0 ] + ( _ascending ? " asc" : " desc" ); } *************** *** 59,62 **** --- 61,66 ---- return new Order( propertyName, false ); } + + private static readonly IDictionary emptyMap = new Hashtable( 0 ); } } \ No newline at end of file Index: SQLExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/SQLExpression.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SQLExpression.cs 31 Dec 2004 17:55:48 -0000 1.8 --- SQLExpression.cs 17 Apr 2005 17:16:05 -0000 1.9 *************** *** 1,2 **** --- 1,3 ---- + using System.Collections; using NHibernate.Engine; using NHibernate.SqlCommand; *************** *** 6,10 **** { /// <summary> ! /// Creates a SQLExpression /// </summary> /// <remarks> --- 7,11 ---- { /// <summary> ! /// An <see cref="ICriterion"/> that creates a SQLExpression /// </summary> /// <remarks> *************** *** 12,19 **** /// write a correct <see cref="SqlString"/>. /// </remarks> ! public class SQLExpression : Expression { ! private readonly SqlString sql; ! private readonly TypedValue[ ] typedValues; /// <summary> --- 13,20 ---- /// write a correct <see cref="SqlString"/>. /// </remarks> ! public class SQLExpression : AbstractCriterion { ! private readonly SqlString _sql; ! private readonly TypedValue[ ] _typedValues; /// <summary> *************** *** 25,33 **** internal SQLExpression( SqlString sql, object[ ] values, IType[ ] types ) { ! this.sql = sql; ! typedValues = new TypedValue[values.Length]; ! for( int i = 0; i < typedValues.Length; i++ ) { ! typedValues[ i ] = new TypedValue( types[ i ], values[ i ] ); } } --- 26,34 ---- internal SQLExpression( SqlString sql, object[ ] values, IType[ ] types ) { ! _sql = sql; ! _typedValues = new TypedValue[values.Length]; ! for( int i = 0; i < _typedValues.Length; i++ ) { ! _typedValues[ i ] = new TypedValue( types[ i ], values[ i ] ); } } *************** *** 40,46 **** /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { ! return sql.Replace( "$alias", alias ); } --- 41,48 ---- /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses ) { ! // TODO: h2.1 SYNCH - need to add an overload to Replace that takes 3 params ! return _sql.Replace( "$alias", alias ); } *************** *** 51,57 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { ! return typedValues; } --- 53,59 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { ! return _typedValues; } *************** *** 59,63 **** public override string ToString() { ! return sql.ToString(); } } --- 61,65 ---- public override string ToString() { ! return _sql.ToString(); } } Index: NotExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/NotExpression.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NotExpression.cs 31 Dec 2004 17:55:06 -0000 1.5 --- NotExpression.cs 17 Apr 2005 17:16:05 -0000 1.6 *************** *** 1,2 **** --- 1,3 ---- + using System.Collections; using NHibernate.Engine; using NHibernate.SqlCommand; *************** *** 5,21 **** { /// <summary> ! /// Negates another expression. /// </summary> ! public class NotExpression : Expression { ! private Expression expression; /// <summary> ! /// /// </summary> ! /// <param name="expression"></param> ! internal NotExpression( Expression expression ) { ! this.expression = expression; } --- 6,23 ---- { /// <summary> ! /// An <see cref="ICriterion"/> that negates another <see cref="ICriterion"/>. /// </summary> ! public class NotExpression : AbstractCriterion { ! private ICriterion _criterion; /// <summary> ! /// Initialize a new instance of the <see cref="NotExpression" /> class for an ! /// <see cref="ICriterion"/> /// </summary> ! /// <param name="criterion">The <see cref="ICriterion"/> to negate.</param> ! internal NotExpression( ICriterion criterion ) { ! _criterion = criterion; } *************** *** 27,36 **** /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { //TODO: set default capacity SqlStringBuilder builder = new SqlStringBuilder(); builder.Add( "not " ); ! builder.Add( expression.ToSqlString( factory, persistentClass, alias ) ); return builder.ToSqlString(); --- 29,39 ---- /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses ) { //TODO: set default capacity SqlStringBuilder builder = new SqlStringBuilder(); builder.Add( "not " ); ! // TODO: h2.1 SYNCH: add a MySqlDialect check ! builder.Add( _criterion.ToSqlString( factory, persistentClass, alias, aliasClasses ) ); return builder.ToSqlString(); *************** *** 43,49 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { ! return expression.GetTypedValues( sessionFactory, persistentClass ); } --- 46,52 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { ! return _criterion.GetTypedValues( sessionFactory, persistentClass, aliasClasses ); } *************** *** 51,55 **** public override string ToString() { ! return "not " + expression.ToString(); } } --- 54,58 ---- public override string ToString() { ! return "not " + _criterion.ToString(); } } Index: LikeExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LikeExpression.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LikeExpression.cs 31 Dec 2004 17:54:36 -0000 1.4 --- LikeExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 *************** *** 2,19 **** { /// <summary> ! /// Summary description for LikeExpression. /// </summary> public class LikeExpression : SimpleExpression { /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="value"></param> internal LikeExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary></summary> protected override string Op { --- 2,28 ---- { /// <summary> ! /// An <see cref="ICriterion"/> that represents an "like" constraint. /// </summary> + /// <remarks> + /// The case sensitivity depends on the database settings for string + /// comparisons. Use <see cref="InsensitiveLikeExpression"/> if the + /// string comparison should not be case sensitive. + /// </remarks> public class LikeExpression : SimpleExpression { /// <summary> ! /// Initialize a new instance of the <see cref="LikeExpression" /> class for a named ! /// Property and its value. /// </summary> ! /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="value">The value for the Property.</param> internal LikeExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary> ! /// Get the Sql operator to use for the <see cref="LikeExpression"/>. ! /// </summary> ! /// <value>The string "<c> like </c>"</value> protected override string Op { Index: EqExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/EqExpression.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EqExpression.cs 31 Dec 2004 17:52:25 -0000 1.5 --- EqExpression.cs 17 Apr 2005 17:16:05 -0000 1.6 *************** *** 2,19 **** { /// <summary> ! /// An Expression that represents an "equal" constraint. /// </summary> public class EqExpression : SimpleExpression { /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="value"></param> internal EqExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary></summary> protected override string Op { --- 2,23 ---- { /// <summary> ! /// An <see cref="ICriterion"/> that represents an "equal" constraint. /// </summary> public class EqExpression : SimpleExpression { /// <summary> ! /// Initialize a new instance of the <see cref="EqExpression" /> class for a named ! /// Property and its value. /// </summary> ! /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="value">The value for the Property.</param> internal EqExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary> ! /// Get the Sql operator to use for the <see cref="EqExpression"/>. ! /// </summary> ! /// <value>The string "<c> = </c>"</value> protected override string Op { Index: OrExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/OrExpression.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OrExpression.cs 31 Dec 2004 17:55:48 -0000 1.4 --- OrExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 *************** *** 2,6 **** { /// <summary> ! /// An Expression that combines two <see cref="Expression"/>s with an /// <c>"or"</c> between them. /// </summary> --- 2,6 ---- { /// <summary> ! /// An <see cref="ICriterion" /> that combines two <see cref="ICriterion"/>s with an /// <c>"or"</c> between them. /// </summary> *************** *** 8,16 **** { /// <summary> ! /// /// </summary> ! /// <param name="lhs"></param> ! /// <param name="rhs"></param> ! internal OrExpression( Expression lhs, Expression rhs ) : base( lhs, rhs ) { } --- 8,17 ---- { /// <summary> ! /// Initialize a new instance of the <see cref="OrExpression" /> class for ! /// two <see cref="ICriterion"/>s. /// </summary> ! /// <param name="lhs">The <see cref="ICriterion"/> to use as the left hand side.</param> ! /// <param name="rhs">The <see cref="ICriterion"/> to use as the right hand side.</param> ! internal OrExpression( ICriterion lhs, ICriterion rhs ) : base( lhs, rhs ) { } Index: AndExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/AndExpression.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AndExpression.cs 31 Dec 2004 17:52:10 -0000 1.4 --- AndExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 *************** *** 2,23 **** { /// <summary> ! /// An Expression that combines two <see cref="Expression"/>s with an ! /// <c>and</c> between them. /// </summary> public class AndExpression : LogicalExpression { /// <summary> ! /// /// </summary> ! /// <param name="lhs"></param> ! /// <param name="rhs"></param> ! internal AndExpression( Expression lhs, Expression rhs ) : base( lhs, rhs ) { } /// <summary> ! /// Get the Sql operator to put between the two <see cref="Expression"/>s. /// </summary> ! /// <value>Returns "<c>and</c>"</value> protected override string Op { --- 2,24 ---- { /// <summary> ! /// An <see cref="LogicalExpression"/> that combines two <see cref="ICriterion"/>s ! /// with an <c>and</c> between them. /// </summary> public class AndExpression : LogicalExpression { /// <summary> ! /// Initializes a new instance of the <see cref="AndExpression"/> class ! /// that combines two <see cref="ICriterion"/>. /// </summary> ! /// <param name="lhs">The <see cref="ICriterion"/> to use as the left hand side.</param> ! /// <param name="rhs">The <see cref="ICriterion"/> to use as the right hand side.</param> ! internal AndExpression( ICriterion lhs, ICriterion rhs ) : base( lhs, rhs ) { } /// <summary> ! /// Get the Sql operator to put between the two <see cref="ICriterion"/>s. /// </summary> ! /// <value>The string "<c>and</c>"</value> protected override string Op { Index: LtPropertyExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LtPropertyExpression.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LtPropertyExpression.cs 31 Dec 2004 17:55:06 -0000 1.2 --- LtPropertyExpression.cs 17 Apr 2005 17:16:05 -0000 1.3 *************** *** 1,18 **** namespace NHibernate.Expression { ! /// <summary></summary> public class LtPropertyExpression : PropertyExpression { /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="otherPropertyName"></param> ! public LtPropertyExpression( string propertyName, string otherPropertyName ) ! : base( propertyName, otherPropertyName ) { } ! /// <summary></summary> protected override string Op { --- 1,25 ---- namespace NHibernate.Expression { ! /// <summary> ! /// An <see cref="ICriterion"/> that represents an "less than" constraint ! /// between two properties. ! /// </summary> public class LtPropertyExpression : PropertyExpression { /// <summary> ! /// Initializes a new instance of the <see cref="LtPropertyExpression"/> class ! /// that compares two mapped properties using an "less than" constraint. /// </summary> ! /// <param name="lhsPropertyName">The name of the Property to use as the left hand side.</param> ! /// <param name="rhsPropertyName">The name of the Property to use as the right hand side.</param> ! public LtPropertyExpression( string lhsPropertyName, string rhsPropertyName ) ! : base( lhsPropertyName, rhsPropertyName ) { } ! /// <summary> ! /// Get the Sql operator to use for the <see cref="LtPropertyExpression"/>. ! /// </summary> ! /// <value>The string "<c> < </c>"</value> protected override string Op { Index: EqPropertyExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/EqPropertyExpression.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EqPropertyExpression.cs 31 Dec 2004 17:52:25 -0000 1.2 --- EqPropertyExpression.cs 17 Apr 2005 17:16:05 -0000 1.3 *************** *** 1,18 **** namespace NHibernate.Expression { ! /// <summary></summary> public class EqPropertyExpression : PropertyExpression { /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="otherPropertyName"></param> ! public EqPropertyExpression( string propertyName, string otherPropertyName ) ! : base( propertyName, otherPropertyName ) { } ! /// <summary></summary> protected override string Op { --- 1,25 ---- namespace NHibernate.Expression { ! /// <summary> ! /// An <see cref="ICriterion"/> that represents an "equal" constraint ! /// between two properties. ! /// </summary> public class EqPropertyExpression : PropertyExpression { /// <summary> ! /// Initializes a new instance of the <see cref="EqPropertyExpression"/> class ! /// that compares two mapped properties using an "equal" constraint. /// </summary> ! /// <param name="lhsPropertyName">The name of the Property to use as the left hand side.</param> ! /// <param name="rhsPropertyName">The name of the Property to use as the right hand side.</param> ! public EqPropertyExpression( string lhsPropertyName, string rhsPropertyName ) ! : base( lhsPropertyName, rhsPropertyName ) { } ! /// <summary> ! /// Get the Sql operator to use for the <see cref="EqPropertyExpression"/>. ! /// </summary> ! /// <value>The string "<c> = </c>"</value> protected override string Op { Index: LtExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LtExpression.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LtExpression.cs 31 Dec 2004 17:55:06 -0000 1.3 --- LtExpression.cs 17 Apr 2005 17:16:05 -0000 1.4 *************** *** 1,17 **** namespace NHibernate.Expression { ! /// <summary></summary> public class LtExpression : SimpleExpression { /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="value"></param> internal LtExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary></summary> protected override string Op { --- 1,23 ---- namespace NHibernate.Expression { ! /// <summary> ! /// An <see cref="ICriterion"/> that represents an "less than" constraint. ! /// </summary> public class LtExpression : SimpleExpression { /// <summary> ! /// Initialize a new instance of the <see cref="LtExpression" /> class for a named ! /// Property and its value. /// </summary> ! /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="value">The value for the Property.</param> internal LtExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary> ! /// Get the Sql operator to use for the <see cref="LtExpression"/>. ! /// </summary> ! /// <value>The string "<c> < </c>"</value> protected override string Op { Index: GeExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/GeExpression.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** GeExpression.cs 31 Dec 2004 17:52:39 -0000 1.4 --- GeExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 *************** *** 1,17 **** namespace NHibernate.Expression { ! /// <summary></summary> public class GeExpression : SimpleExpression { /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="value"></param> internal GeExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary></summary> protected override string Op { --- 1,23 ---- namespace NHibernate.Expression { ! /// <summary> ! /// An <see cref="ICriterion"/> that represents an "greater than or equal" constraint. ! /// </summary> public class GeExpression : SimpleExpression { /// <summary> ! /// Initialize a new instance of the <see cref="GeExpression" /> class for a named ! /// Property and its value. /// </summary> ! /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="value">The value for the Property.</param> internal GeExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary> ! /// Get the Sql operator to use for the <see cref="GeExpression"/>. ! /// </summary> ! /// <value>The string "<c> >= </c>"</value> protected override string Op { Index: ICriterion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/ICriterion.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ICriterion.cs 1 Mar 2005 16:25:08 -0000 1.1 --- ICriterion.cs 17 Apr 2005 17:16:05 -0000 1.2 *************** *** 1,7 **** using System.Collections; using NHibernate.Engine; - using NHibernate.Persister; using NHibernate.SqlCommand; - using NHibernate.Type; namespace NHibernate.Expression --- 1,5 ---- *************** *** 9,13 **** /// <summary> /// An object-oriented representation of a query criterion that may be used as a constraint ! /// in a <c>Criteria</c> query. /// </summary> /// <remarks> --- 7,11 ---- /// <summary> /// An object-oriented representation of a query criterion that may be used as a constraint ! /// in a <see cref="ICriteria"/> query. /// </summary> /// <remarks> *************** *** 19,38 **** { /// <summary> ! /// /// </summary> ! /// <param name="sessionFactory"></param> ! /// <param name="persistentClass"></param> ! /// <param name="alias"></param> /// <param name="aliasClasses"></param> ! /// <returns></returns> SqlString ToSqlString( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, string alias, IDictionary aliasClasses ); /// <summary> ! /// /// </summary> ! /// <param name="sessionFactory"></param> ! /// <param name="persistentClass"></param> ! /// <param name="aliasClasses"></param> ! /// <returns></returns> TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ); } --- 17,35 ---- { /// <summary> ! /// Render a SqlString fragment for the expression. /// </summary> ! /// <param name="sessionFactory">The ISessionFactory that contains the mapping for the Type.</param> ! /// <param name="persistentClass">The Class the Expression is being built for.</param> ! /// <param name="alias">The alias to use for the table.</param> /// <param name="aliasClasses"></param> ! /// <returns>A SqlString that contains a valid Sql fragment.</returns> SqlString ToSqlString( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, string alias, IDictionary aliasClasses ); /// <summary> ! /// Return typed values for all parameters in the rendered SQL fragment /// </summary> ! /// <param name="sessionFactory">The ISessionFactory that contains the mapping for the Type.</param> ! /// <param name="persistentClass">The Class the Expression is being built for.</param> ! /// <returns>An array of TypedValues for the Expression.</returns> TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ); } Index: AbstractCriterion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/AbstractCriterion.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractCriterion.cs 1 Mar 2005 16:25:08 -0000 1.1 --- AbstractCriterion.cs 17 Apr 2005 17:16:05 -0000 1.2 *************** *** 1,2 **** --- 1,3 ---- + using System; using System.Collections; using NHibernate.Engine; *************** *** 9,18 **** { /// <summary> ! /// Summary description for AbstractCriterion. /// </summary> public abstract class AbstractCriterion : ICriterion { /// <summary> ! /// /// </summary> protected AbstractCriterion() --- 10,21 ---- { /// <summary> ! /// Base class for <see cref="ICriterion"/> implementations. /// </summary> public abstract class AbstractCriterion : ICriterion { + private static readonly IDictionary EmptyDictionary = new Hashtable( 0 ); + /// <summary> ! /// Initializes a new instance of the <see cref="AbstractCriterion"/> class. /// </summary> protected AbstractCriterion() *************** *** 25,28 **** --- 28,36 ---- } + protected internal static string[] GetColumns(ISessionFactoryImplementor factory, System.Type persistentClass, string property) + { + return AbstractCriterion.GetColumns( factory, persistentClass, property, null, AbstractCriterion.EmptyDictionary ); + } + /// <summary> /// *************** *** 34,43 **** /// <param name="aliasClasses"></param> /// <returns></returns> ! protected static string[] GetColumns( ISessionFactoryImplementor factory, System.Type persistentClass, string property, string alias, IDictionary aliasClasses ) { if ( property.IndexOf( '.' ) > 0 ) { string root = StringHelper.Root( property ); ! System.Type clazz = (System.Type) aliasClasses[ root ]; if ( clazz != null ) { --- 42,51 ---- /// <param name="aliasClasses"></param> /// <returns></returns> ! protected internal static string[] GetColumns( ISessionFactoryImplementor factory, System.Type persistentClass, string property, string alias, IDictionary aliasClasses ) { if ( property.IndexOf( '.' ) > 0 ) { string root = StringHelper.Root( property ); ! System.Type clazz = aliasClasses[ root ] as System.Type; if ( clazz != null ) { *************** *** 48,56 **** } ! return GetPropertyMapping( persistentClass, factory ).ToColumns( alias, property ); } /// <summary> ! /// /// </summary> /// <param name="factory"></param> --- 56,64 ---- } ! return AbstractCriterion.GetPropertyMapping( persistentClass, factory ).ToColumns( alias, property ); } /// <summary> ! /// Get the a typed value for the given property value. /// </summary> /// <param name="factory"></param> *************** *** 72,80 **** } ! return GetPropertyMapping( persistentClass, factory ).ToType( property ); } /// <summary> ! /// /// </summary> /// <param name="factory"></param> --- 80,88 ---- } ! return AbstractCriterion.GetPropertyMapping( persistentClass, factory ).ToType( property ); } /// <summary> ! /// Get the <see cref="TypedValue"/> for the given property value. /// </summary> /// <param name="factory"></param> *************** *** 86,111 **** protected static TypedValue GetTypedValue( ISessionFactoryImplementor factory, System.Type persistentClass, string property, object value, IDictionary aliasClasses ) { ! return new TypedValue( GetType( factory, persistentClass, property, aliasClasses), value ); } #region ICriterion Members /// <summary> ! /// /// </summary> ! /// <param name="sessionFactory"></param> ! /// <param name="persistentClass"></param> ! /// <param name="alias"></param> /// <param name="aliasClasses"></param> ! /// <returns></returns> ! public abstract SqlString ToSqlString(ISessionFactoryImplementor sessionFactory, System.Type persistentClass, string alias, IDictionary aliasClasses); /// <summary> ! /// /// </summary> ! /// <param name="sessionFactory"></param> ! /// <param name="persistentClass"></param> /// <param name="aliasClasses"></param> ! /// <returns></returns> public abstract TypedValue[] GetTypedValues(ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses); --- 94,131 ---- protected static TypedValue GetTypedValue( ISessionFactoryImplementor factory, System.Type persistentClass, string property, object value, IDictionary aliasClasses ) { ! return new TypedValue( AbstractCriterion.GetType( factory, persistentClass, property, aliasClasses), value ); } + /// <summary> + /// Gets a string representation of the <see cref="AbstractCriterion"/>. + /// </summary> + /// <returns> + /// A String that shows the contents of the <see cref="AbstractCriterion"/>. + /// </returns> + /// <remarks> + /// This is not a well formed Sql fragment. It is useful for logging what the <see cref="AbstractCriterion"/> + /// looks like. + /// </remarks> + public abstract override string ToString(); + #region ICriterion Members /// <summary> ! /// Render a SqlString for the expression. /// </summary> ! /// <param name="factory">The ISessionFactory that contains the mapping for the Type.</param> ! /// <param name="persistentClass">The Class the Expression is being built for.</param> ! /// <param name="alias">The alias to use for the table.</param> /// <param name="aliasClasses"></param> ! /// <returns>A SqlString that contains a valid Sql fragment.</returns> ! public abstract SqlString ToSqlString(ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses); /// <summary> ! /// Return typed values for all parameters in the rendered SQL fragment /// </summary> ! /// <param name="sessionFactory">The ISessionFactory that contains the mapping for the Type.</param> ! /// <param name="persistentClass">The Class the Expression is being built for.</param> /// <param name="aliasClasses"></param> ! /// <returns>An array of TypedValues for the Expression.</returns> public abstract TypedValue[] GetTypedValues(ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses); Index: BetweenExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/BetweenExpression.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** BetweenExpression.cs 31 Dec 2004 17:52:10 -0000 1.6 --- BetweenExpression.cs 17 Apr 2005 17:16:05 -0000 1.7 *************** *** 1,2 **** --- 1,4 ---- + using System; + using System.Collections; using NHibernate.Engine; using NHibernate.Persister; *************** *** 7,20 **** { /// <summary> ! /// An Expression that represents a "between" constraint. /// </summary> ! public class BetweenExpression : Expression { ! private readonly string propertyName; ! private readonly object lo; ! private readonly object hi; /// <summary> ! /// Initialize a new instance of the BetweenExpression class for /// the named Property. /// </summary> --- 9,22 ---- { /// <summary> ! /// An <see cref="ICriterion"/> that represents a "between" constraint. /// </summary> ! public class BetweenExpression : AbstractCriterion { ! private readonly string _propertyName; ! private readonly object _lo; ! private readonly object _hi; /// <summary> ! /// Initialize a new instance of the <see cref="BetweenExpression" /> class for /// the named Property. /// </summary> *************** *** 24,30 **** internal BetweenExpression( string propertyName, object lo, object hi ) { ! this.propertyName = propertyName; ! this.lo = lo; ! this.hi = hi; } --- 26,32 ---- internal BetweenExpression( string propertyName, object lo, object hi ) { ! _propertyName = propertyName; ! _lo = lo; ! _hi = hi; } *************** *** 36,47 **** /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { //TODO: add a default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( propertyName ); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); ! string[ ] paramColumnNames = GetColumns( factory, persistentClass, propertyName, null ); string[ ] loParamColumnNames = new string[paramColumnNames.Length]; string[ ] hiParamColumnNames = new string[paramColumnNames.Length]; --- 38,50 ---- /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses ) { //TODO: add a default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( _propertyName ); ! string[ ] columnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName, alias, aliasClasses ); ! // don't need to worry about aliasing or aliasClassing for parameter column names ! string[ ] paramColumnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName ); string[ ] loParamColumnNames = new string[paramColumnNames.Length]; string[ ] hiParamColumnNames = new string[paramColumnNames.Length]; *************** *** 55,63 **** } - Parameter[ ] parameters = new Parameter[paramColumnNames.Length*2]; Parameter[ ] loParameters = Parameter.GenerateParameters( factory, alias, loParamColumnNames, propertyType ); Parameter[ ] hiParameters = Parameter.GenerateParameters( factory, alias, hiParamColumnNames, propertyType ); - - bool andNeeded = false; --- 58,63 ---- *************** *** 86,95 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { return new TypedValue[ ] { ! GetTypedValue( sessionFactory, persistentClass, propertyName, lo ), ! GetTypedValue( sessionFactory, persistentClass, propertyName, hi ) }; } --- 86,95 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { return new TypedValue[ ] { ! AbstractCriterion.G... [truncated message content] |