From: Kevin W. <kev...@us...> - 2004-12-31 17:55:45
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22938 Modified Files: NotNullExpression.cs NullExpression.cs Order.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: Order.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/Order.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Order.cs 28 Mar 2004 06:05:09 -0000 1.4 --- Order.cs 31 Dec 2004 17:55:35 -0000 1.5 *************** *** 1,15 **** - using System; - using NHibernate.Engine; ! namespace NHibernate.Expression { - /// <summary> /// Represents an order imposed upon a ICriteria result set /// </summary> ! public class Order { - private bool ascending; private string propertyName; --- 1,11 ---- using NHibernate.Engine; ! namespace NHibernate.Expression { /// <summary> /// Represents an order imposed upon a ICriteria result set /// </summary> ! public class Order { private bool ascending; private string propertyName; *************** *** 20,30 **** /// <param name="propertyName"></param> /// <param name="ascending"></param> ! protected Order(string propertyName, bool ascending) { this.propertyName = propertyName; this.ascending = ascending; } ! ! /// <summary> /// Render the SQL fragment --- 16,26 ---- /// <param name="propertyName"></param> /// <param name="ascending"></param> ! protected Order( string propertyName, bool ascending ) { this.propertyName = propertyName; this.ascending = ascending; } ! ! /// <summary> /// Render the SQL fragment *************** *** 34,44 **** /// <param name="alias"></param> /// <returns></returns> ! 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" ); } ! /// <summary> /// Ascending order --- 30,43 ---- /// <param name="alias"></param> /// <returns></returns> ! 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" ); } ! /// <summary> /// Ascending order *************** *** 46,54 **** /// <param name="propertyName"></param> /// <returns></returns> ! public static Order Asc(string propertyName) { ! return new Order(propertyName, true); } ! /// <summary> /// Descending order --- 45,53 ---- /// <param name="propertyName"></param> /// <returns></returns> ! public static Order Asc( string propertyName ) { ! return new Order( propertyName, true ); } ! /// <summary> /// Descending order *************** *** 56,62 **** /// <param name="propertyName"></param> /// <returns></returns> ! public static Order Desc(string propertyName) { ! return new Order(propertyName, false); } } --- 55,61 ---- /// <param name="propertyName"></param> /// <returns></returns> ! public static Order Desc( string propertyName ) { ! return new Order( propertyName, false ); } } Index: NotNullExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/NotNullExpression.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NotNullExpression.cs 28 Mar 2004 06:05:09 -0000 1.5 --- NotNullExpression.cs 31 Dec 2004 17:55:35 -0000 1.6 *************** *** 1,48 **** - using System; - using System.Text; - using NHibernate.Engine; using NHibernate.Persister; using NHibernate.SqlCommand; using NHibernate.Type; - using NHibernate.Util; ! 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]; ! ! internal NotNullExpression(string propertyName) { this.propertyName = propertyName; } ! ! 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); ! ! bool andNeeded = false; ! ! for(int i = 0; i < columnNames.Length; i++) { ! if(andNeeded) sqlBuilder.Add(" AND "); andNeeded = true; ! sqlBuilder.Add(columnNames[i]) ! .Add(" IS NOT NULL"); } --- 1,55 ---- 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; } ! /// <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 ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( propertyName ); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); ! ! bool andNeeded = false; ! ! for( int i = 0; i < columnNames.Length; i++ ) { ! if( andNeeded ) ! { ! sqlBuilder.Add( " AND " ); ! } andNeeded = true; ! sqlBuilder.Add( columnNames[ i ] ) ! .Add( " IS NOT NULL" ); } *************** *** 50,60 **** return sqlBuilder.ToSqlString(); } ! ! public override TypedValue[] GetTypedValues(ISessionFactoryImplementor sessionFactory, System.Type persistentClass) { return NoValues; } ! public override string ToString() { return propertyName + " is not null"; --- 57,74 ---- return sqlBuilder.ToSqlString(); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="sessionFactory"></param> ! /// <param name="persistentClass"></param> ! /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { return NoValues; } ! /// <summary></summary> ! public override string ToString() { return propertyName + " is not null"; Index: NullExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/NullExpression.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NullExpression.cs 28 Mar 2004 06:05:09 -0000 1.5 --- NullExpression.cs 31 Dec 2004 17:55:35 -0000 1.6 *************** *** 1,43 **** - using System; - using System.Text; - using NHibernate.Engine; using NHibernate.Persister; using NHibernate.SqlCommand; using NHibernate.Type; - using NHibernate.Util; ! namespace NHibernate.Expression { - /// <summary> /// Constrains a property to be null /// </summary> ! public class NullExpression : Expression { - private readonly string propertyName; ! ! private static readonly TypedValue[] NoValues = new TypedValue[0]; ! ! internal NullExpression(string propertyName) { this.propertyName = propertyName; } ! 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); ! ! for(int i = 0; i < columnNames.Length; i++) { ! if(i > 0) sqlBuilder.Add(" AND "); ! ! sqlBuilder.Add(columnNames[i]) ! .Add(" IS NULL"); } --- 1,51 ---- using NHibernate.Engine; using NHibernate.Persister; using NHibernate.SqlCommand; using NHibernate.Type; ! namespace NHibernate.Expression { /// <summary> /// Constrains a property to be null /// </summary> ! public class NullExpression : Expression { private readonly string propertyName; ! ! private static readonly TypedValue[ ] NoValues = new TypedValue[0]; ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="propertyName"></param> ! internal NullExpression( string propertyName ) { this.propertyName = propertyName; } ! /// <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 ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( propertyName ); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); ! ! for( int i = 0; i < columnNames.Length; i++ ) { ! if( i > 0 ) ! { ! sqlBuilder.Add( " AND " ); ! } ! ! sqlBuilder.Add( columnNames[ i ] ) ! .Add( " IS NULL" ); } *************** *** 45,55 **** return sqlBuilder.ToSqlString(); } ! ! public override TypedValue[] GetTypedValues(ISessionFactoryImplementor sessionFactory, System.Type persistentClass) { return NoValues; } ! public override string ToString() { return propertyName + " is null"; --- 53,70 ---- return sqlBuilder.ToSqlString(); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="sessionFactory"></param> ! /// <param name="persistentClass"></param> ! /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { return NoValues; } ! /// <summary></summary> ! public override string ToString() { return propertyName + " is null"; |