|
From: <fab...@us...> - 2010-09-22 19:57:50
|
Revision: 5201
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5201&view=rev
Author: fabiomaulo
Date: 2010-09-22 19:57:43 +0000 (Wed, 22 Sep 2010)
Log Message:
-----------
Fix NH-2289
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/NhRelinqQueryParser.cs
trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/NhRelinqQueryParser.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/NhRelinqQueryParser.cs 2010-09-22 17:05:14 UTC (rev 5200)
+++ trunk/nhibernate/src/NHibernate/Linq/NhRelinqQueryParser.cs 2010-09-22 19:57:43 UTC (rev 5201)
@@ -29,15 +29,17 @@
},
typeof (AggregateExpressionNode));
- MethodCallRegistry.Register(
- new[]
- {
- MethodCallExpressionNodeTypeRegistry.GetRegisterableMethodDefinition(
- ReflectionHelper.GetMethodDefinition((List<object> l) => l.Contains(null))),
+ // Here would be useful to have something like our ReflectionHelper.IsMethodOf because it is impossible to know
+ // which is the implementation of ICollection<T> used by our user. Reported to Stefan Wenig as possible (via mail instead of their JIAR)
+ MethodCallRegistry.Register(
+ new[]
+ {
+ MethodCallExpressionNodeTypeRegistry.GetRegisterableMethodDefinition(
+ ReflectionHelper.GetMethodDefinition((List<object> l) => l.Contains(null))),
+ typeof (ICollection<>).GetMethod("Contains"),
+ },
+ typeof (ContainsExpressionNode));
- },
- typeof (ContainsExpressionNode));
-
MethodCallRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("Fetch") }, typeof(FetchOneExpressionNode));
MethodCallRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("FetchMany") }, typeof(FetchManyExpressionNode));
MethodCallRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("ThenFetch") }, typeof(ThenFetchOneExpressionNode));
Modified: trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs 2010-09-22 17:05:14 UTC (rev 5200)
+++ trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs 2010-09-22 19:57:43 UTC (rev 5201)
@@ -326,7 +326,7 @@
Assert.AreEqual(2, query.Count);
}
- [Test, Ignore("Not fixed yet NH-2289")]
+ [Test]
public void WhenTheSourceOfConstantIsICollectionThenNoThrows()
{
ICollection<string> names = new List<string> {"ayende", "rahien"};
@@ -340,6 +340,19 @@
}
[Test]
+ public void WhenTheSourceOfConstantIsIListThenNoThrows()
+ {
+ IList<string> names = new List<string> { "ayende", "rahien" };
+
+ var query = (from user in db.Users
+ where names.Contains(user.Name)
+ select user);
+ List<User> result = null;
+ Executing.This(() => result = query.ToList()).Should().NotThrow();
+ result.Count.Should().Be(2);
+ }
+
+ [Test]
public void TimesheetsWithCollectionContains()
{
var entry = session.Get<TimesheetEntry>(1);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|