|
From: <fab...@us...> - 2010-12-15 22:09:25
|
Revision: 5318
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5318&view=rev
Author: fabiomaulo
Date: 2010-12-15 22:09:18 +0000 (Wed, 15 Dec 2010)
Log Message:
-----------
Fix NH-2461
Modified Paths:
--------------
trunk/nhibernate/releasenotes.txt
trunk/nhibernate/src/NHibernate/Criterion/Restrictions.cs
trunk/nhibernate/src/NHibernate/IQuery.cs
trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs
Modified: trunk/nhibernate/releasenotes.txt
===================================================================
--- trunk/nhibernate/releasenotes.txt 2010-12-15 21:57:25 UTC (rev 5317)
+++ trunk/nhibernate/releasenotes.txt 2010-12-15 22:09:18 UTC (rev 5318)
@@ -1,3 +1,7 @@
+** Known BREAKING CHANGES from NH3.0.0.GA to NH3.0.1.GA
+ ##### Possible Breaking Changes #####
+ * [NH-2461] - Signature change for IQuery.SetParameterList
+
** Known BREAKING CHANGES from NH2.1.1.GA to NH3.0.0.GA
##### Design time #####
Modified: trunk/nhibernate/src/NHibernate/Criterion/Restrictions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/Restrictions.cs 2010-12-15 21:57:25 UTC (rev 5317)
+++ trunk/nhibernate/src/NHibernate/Criterion/Restrictions.cs 2010-12-15 22:09:18 UTC (rev 5318)
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Linq;
using System.Linq.Expressions;
using NHibernate.Criterion.Lambda;
using NHibernate.Impl;
@@ -299,14 +300,14 @@
/// of <see cref="In(string, ICollection)" />, renamed to avoid ambiguity.
/// </summary>
/// <param name="propertyName">The name of the Property in the class.</param>
- /// <param name="values">An <see cref="System.Collections.Generic.ICollection{T}" />
+ /// <param name="values">An <see cref="System.Collections.Generic.IEnumerable{T}" />
/// of values.</param>
/// <returns>An <see cref="InExpression" />.</returns>
- public static AbstractCriterion InG<T>(string propertyName, ICollection<T> values)
+ public static AbstractCriterion InG<T>(string propertyName, IEnumerable<T> values)
{
- object[] array = new object[values.Count];
- int i = 0;
- foreach (T item in values)
+ var array = new object[values.Count()];
+ var i = 0;
+ foreach (var item in values)
{
array[i] = item;
i++;
@@ -320,14 +321,14 @@
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="projection">The projection.</param>
- /// <param name="values">An <see cref="System.Collections.Generic.ICollection{T}"/>
+ /// <param name="values">An <see cref="System.Collections.Generic.IEnumerable{T}"/>
/// of values.</param>
/// <returns>An <see cref="InExpression"/>.</returns>
- public static AbstractCriterion InG<T>(IProjection projection, ICollection<T> values)
+ public static AbstractCriterion InG<T>(IProjection projection, IEnumerable<T> values)
{
- object[] array = new object[values.Count];
- int i = 0;
- foreach (T item in values)
+ var array = new object[values.Count()];
+ var i = 0;
+ foreach (var item in values)
{
array[i] = item;
i++;
Modified: trunk/nhibernate/src/NHibernate/IQuery.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/IQuery.cs 2010-12-15 21:57:25 UTC (rev 5317)
+++ trunk/nhibernate/src/NHibernate/IQuery.cs 2010-12-15 22:09:18 UTC (rev 5318)
@@ -255,7 +255,7 @@
/// <param name="name">The name of the parameter</param>
/// <param name="vals">A collection of values to list</param>
/// <param name="type">The NHibernate type of the values</param>
- IQuery SetParameterList(string name, ICollection vals, IType type);
+ IQuery SetParameterList(string name, IEnumerable vals, IType type);
/// <summary>
/// Bind multiple values to a named query parameter, guessing the NHibernate
@@ -264,28 +264,9 @@
/// </summary>
/// <param name="name">The name of the parameter</param>
/// <param name="vals">A collection of values to list</param>
- IQuery SetParameterList(string name, ICollection vals);
+ IQuery SetParameterList(string name, IEnumerable vals);
/// <summary>
- /// Bind multiple values to a named query parameter. This is useful for binding
- /// a list of values to an expression such as <tt>foo.bar in (:value_list)</tt>.
- /// </summary>
- /// <param name="name">the name of the parameter </param>
- /// <param name="vals">a collection of values to list </param>
- /// <param name="type">the NHibernate type of the values </param>
- IQuery SetParameterList(string name, object[] vals, IType type);
-
- /// <summary>
- /// Bind multiple values to a named query parameter. The NHibernate type of the parameter is
- /// first detected via the usage/position in the query and if not sufficient secondly
- /// guessed from the class of the first object in the array. This is useful for binding a list of values
- /// to an expression such as <tt>foo.bar in (:value_list)</tt>.
- /// </summary>
- /// <param name="name">the name of the parameter </param>
- /// <param name="vals">a collection of values to list </param>
- IQuery SetParameterList(string name, object[] vals);
-
- /// <summary>
/// Bind the property values of the given object to named parameters of the query,
/// matching property names with parameter names and mapping property types to
/// NHibernate types using heuristics.
Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2010-12-15 21:57:25 UTC (rev 5317)
+++ trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2010-12-15 22:09:18 UTC (rev 5318)
@@ -648,7 +648,7 @@
return this;
}
- public IQuery SetParameterList(string name, ICollection vals, IType type)
+ public IQuery SetParameterList(string name, IEnumerable vals, IType type)
{
if (!parameterMetadata.NamedParameterNames.Contains(name))
{
@@ -661,7 +661,7 @@
{
throw new ArgumentNullException("type","Can't determine the type of parameter-list elements.");
}
- if(vals.Count == 0)
+ if(!vals.Any())
{
throw new QueryException(string.Format("An empty parameter-list generate wrong SQL; parameter name '{0}'", name));
}
@@ -669,7 +669,7 @@
return this;
}
- public IQuery SetParameterList(string name, ICollection vals)
+ public IQuery SetParameterList(string name, IEnumerable vals)
{
if (vals == null)
{
@@ -682,30 +682,11 @@
return this;
}
- if (vals.Count == 0)
- {
- SetParameterList(name, vals, GuessType(vals.GetCollectionElementType()));
- }
- else
- {
- IEnumerator iter = vals.GetEnumerator();
- iter.MoveNext();
- SetParameterList(name, vals, DetermineType(name, iter.Current));
- }
+ SetParameterList(name, vals, !vals.Any() ? GuessType(vals.GetCollectionElementType()) : DetermineType(name, vals.First()));
return this;
}
- public IQuery SetParameterList(string name, object[] vals, IType type)
- {
- return SetParameterList(name, vals as ICollection, type);
- }
-
- public IQuery SetParameterList(string name, object[] vals)
- {
- return SetParameterList(name, vals as ICollection);
- }
-
#endregion
#region Query properties
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|