You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
| 2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
| 2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
| 2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
| 2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
| 2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
| 2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
| 2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
| 2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
| 2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <fab...@us...> - 2010-07-29 13:11:06
|
Revision: 5081
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5081&view=rev
Author: fabiomaulo
Date: 2010-07-29 13:10:59 +0000 (Thu, 29 Jul 2010)
Log Message:
-----------
Minor (example of custom LINQ extensions)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/Linq/CustomExtensionsExample.cs
Added: trunk/nhibernate/src/NHibernate.Test/Linq/CustomExtensionsExample.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Linq/CustomExtensionsExample.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Linq/CustomExtensionsExample.cs 2010-07-29 13:10:59 UTC (rev 5081)
@@ -0,0 +1,67 @@
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using System.Text.RegularExpressions;
+using NHibernate.Cfg.Loquacious;
+using NHibernate.Hql.Ast;
+using NHibernate.Linq;
+using NHibernate.Linq.Functions;
+using NHibernate.Linq.Visitors;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.Linq
+{
+ public static class MyLinqExtensions
+ {
+ public static bool IsLike(this string source, string pattern)
+ {
+ pattern = Regex.Escape(pattern);
+ pattern = pattern.Replace("%", ".*?").Replace("_", ".");
+ pattern = pattern.Replace(@"\[", "[").Replace(@"\]","]").Replace(@"\^", "^");
+
+ return Regex.IsMatch(source, pattern);
+ }
+ }
+
+ public class MyLinqToHqlGeneratorsRegistry: DefaultLinqToHqlGeneratorsRegistry
+ {
+ public MyLinqToHqlGeneratorsRegistry():base()
+ {
+ RegisterGenerator(ReflectionHelper.GetMethod(() => MyLinqExtensions.IsLike(null, null)),
+ new IsLikeGenerator());
+ }
+ }
+
+ public class IsLikeGenerator : BaseHqlGeneratorForMethod
+ {
+ public IsLikeGenerator()
+ {
+ SupportedMethods = new[] {ReflectionHelper.GetMethod(() => MyLinqExtensions.IsLike(null, null))};
+ }
+
+ public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject,
+ ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
+ {
+ return treeBuilder.Like(visitor.Visit(arguments[0]).AsExpression(),
+ visitor.Visit(arguments[1]).AsExpression());
+ }
+ }
+
+ public class CustomExtensionsExample : LinqTestCase
+ {
+ protected override void Configure(NHibernate.Cfg.Configuration configuration)
+ {
+ configuration.LinqToHqlGeneratorsRegistry<MyLinqToHqlGeneratorsRegistry>();
+ }
+
+ [Test]
+ public void CanUseMyCustomExtension()
+ {
+ var contacts = (from c in db.Customers where c.ContactName.IsLike("%Thomas%") select c).ToList();
+ contacts.Count.Should().Be.GreaterThan(0);
+ contacts.Select(customer => customer.ContactName).All(c => c.Satisfy(customer => customer.Contains("Thomas")));
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-28 22:34:55 UTC (rev 5080)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-29 13:10:59 UTC (rev 5081)
@@ -395,6 +395,7 @@
<Compile Include="Linq\BinaryExpressionOrdererTests.cs" />
<Compile Include="Linq\CasingTest.cs" />
<Compile Include="Linq\CollectionAssert.cs" />
+ <Compile Include="Linq\CustomExtensionsExample.cs" />
<Compile Include="Linq\DateTimeTests.cs" />
<Compile Include="Linq\DynamicQueryTests.cs" />
<Compile Include="Linq\EagerLoadTests.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 22:35:02
|
Revision: 5080
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5080&view=rev
Author: fabiomaulo
Date: 2010-07-28 22:34:55 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Refactoring (removed unneeded method)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs 2010-07-28 22:21:16 UTC (rev 5079)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs 2010-07-28 22:34:55 UTC (rev 5080)
@@ -12,7 +12,6 @@
public DefaultLinqToHqlGeneratorsRegistry()
{
- // TODO - could use reflection here
Register(new StandardLinqExtensionMethodGenerator());
Register(new QueryableGenerator());
Register(new StringGenerator());
@@ -32,15 +31,6 @@
return false;
}
- protected bool GetRegisteredMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
- {
- if (registeredMethods.TryGetValue(method, out methodGenerator))
- {
- return true;
- }
- return false;
- }
-
public virtual bool TryGetGenerator(MethodInfo method, out IHqlGeneratorForMethod generator)
{
if (method.IsGenericMethod)
@@ -48,7 +38,7 @@
method = method.GetGenericMethodDefinition();
}
- if (GetRegisteredMethodGenerator(method, out generator)) return true;
+ if (registeredMethods.TryGetValue(method, out generator)) return true;
// Not that either. Let's query each type generator to see if it can handle it
if (GetMethodGeneratorForType(method, out generator)) return true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 22:21:22
|
Revision: 5079
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5079&view=rev
Author: fabiomaulo
Date: 2010-07-28 22:21:16 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Minor (cleaned)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs 2010-07-28 22:19:19 UTC (rev 5078)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs 2010-07-28 22:21:16 UTC (rev 5079)
@@ -1,10 +1,6 @@
using System.Collections.Generic;
-using System.Collections.ObjectModel;
using System.Linq;
-using System.Linq.Expressions;
using System.Reflection;
-using NHibernate.Hql.Ast;
-using NHibernate.Linq.Visitors;
namespace NHibernate.Linq.Functions
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 22:19:27
|
Revision: 5078
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5078&view=rev
Author: fabiomaulo
Date: 2010-07-28 22:19:19 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Refactoring (extracted StandardLinqExtensionMethodGenerator as an IHqlGeneratorForType)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Linq/Functions/StandardLinqExtensionMethodGenerator.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs 2010-07-28 21:42:28 UTC (rev 5077)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs 2010-07-28 22:19:19 UTC (rev 5078)
@@ -17,6 +17,7 @@
public DefaultLinqToHqlGeneratorsRegistry()
{
// TODO - could use reflection here
+ Register(new StandardLinqExtensionMethodGenerator());
Register(new QueryableGenerator());
Register(new StringGenerator());
Register(new DateTimeGenerator());
@@ -35,21 +36,6 @@
return false;
}
- protected bool GetStandardLinqExtensionMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
- {
- methodGenerator = null;
-
- var attr = method.GetCustomAttributes(typeof(LinqExtensionMethodAttribute), false);
-
- if (attr.Length == 1)
- {
- // It is
- methodGenerator = new HqlGeneratorForExtensionMethod((LinqExtensionMethodAttribute)attr[0], method);
- return true;
- }
- return false;
- }
-
protected bool GetRegisteredMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
{
if (registeredMethods.TryGetValue(method, out methodGenerator))
@@ -68,9 +54,6 @@
if (GetRegisteredMethodGenerator(method, out generator)) return true;
- // No method generator registered. Look to see if it's a standard LinqExtensionMethod
- if (GetStandardLinqExtensionMethodGenerator(method, out generator)) return true;
-
// Not that either. Let's query each type generator to see if it can handle it
if (GetMethodGeneratorForType(method, out generator)) return true;
@@ -98,36 +81,4 @@
typeMethodGenerator.Register(this);
}
}
-
- public class HqlGeneratorForExtensionMethod : BaseHqlGeneratorForMethod
- {
- private readonly string _name;
-
- public HqlGeneratorForExtensionMethod(LinqExtensionMethodAttribute attribute, MethodInfo method)
- {
- _name = string.IsNullOrEmpty(attribute.Name) ? method.Name : attribute.Name;
- }
-
- public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
- {
- var args = visitor.Visit(targetObject)
- .Union(arguments.Select(a => visitor.Visit(a)))
- .Cast<HqlExpression>();
-
- return treeBuilder.MethodCall(_name, args);
- }
- }
-
- static class UnionExtension
- {
- public static IEnumerable<HqlTreeNode> Union(this HqlTreeNode first, IEnumerable<HqlTreeNode> rest)
- {
- yield return first;
-
- foreach (var x in rest)
- {
- yield return x;
- }
- }
- }
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Linq/Functions/StandardLinqExtensionMethodGenerator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/StandardLinqExtensionMethodGenerator.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/StandardLinqExtensionMethodGenerator.cs 2010-07-28 22:19:19 UTC (rev 5078)
@@ -0,0 +1,64 @@
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using NHibernate.Hql.Ast;
+using NHibernate.Linq.Visitors;
+
+namespace NHibernate.Linq.Functions
+{
+ public class StandardLinqExtensionMethodGenerator : IHqlGeneratorForType
+ {
+ #region IHqlGeneratorForType Members
+
+ public void Register(ILinqToHqlGeneratorsRegistry functionRegistry)
+ {
+ // nothing to do
+ }
+
+ public bool SupportsMethod(MethodInfo method)
+ {
+ return method.GetCustomAttributes(typeof (LinqExtensionMethodAttribute), false).Any();
+ }
+
+ public IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method)
+ {
+ return new HqlGeneratorForExtensionMethod((LinqExtensionMethodAttribute) method.GetCustomAttributes(typeof (LinqExtensionMethodAttribute), false).First(), method);
+ }
+
+ #endregion
+ }
+
+ public class HqlGeneratorForExtensionMethod : BaseHqlGeneratorForMethod
+ {
+ private readonly string _name;
+
+ public HqlGeneratorForExtensionMethod(LinqExtensionMethodAttribute attribute, MethodInfo method)
+ {
+ _name = string.IsNullOrEmpty(attribute.Name) ? method.Name : attribute.Name;
+ }
+
+ public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
+ {
+ var args = visitor.Visit(targetObject)
+ .Union(arguments.Select(a => visitor.Visit(a)))
+ .Cast<HqlExpression>();
+
+ return treeBuilder.MethodCall(_name, args);
+ }
+ }
+
+ static class UnionExtension
+ {
+ public static IEnumerable<HqlTreeNode> Union(this HqlTreeNode first, IEnumerable<HqlTreeNode> rest)
+ {
+ yield return first;
+
+ foreach (var x in rest)
+ {
+ yield return x;
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-07-28 21:42:28 UTC (rev 5077)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-07-28 22:19:19 UTC (rev 5078)
@@ -656,6 +656,7 @@
<Compile Include="Linq\EagerFetchingExtensionMethods.cs" />
<Compile Include="Linq\Functions\ILinqToHqlGeneratorsRegistry.cs" />
<Compile Include="Linq\Functions\LinqToHqlGeneratorsRegistryFactory.cs" />
+ <Compile Include="Linq\Functions\StandardLinqExtensionMethodGenerator.cs" />
<Compile Include="Linq\LinqExtensionMethodAttribute.cs" />
<Compile Include="Linq\TypeHelperExtensionMethods.cs" />
<Compile Include="Linq\Visitors\NameUnNamedParameters.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 21:42:37
|
Revision: 5077
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5077&view=rev
Author: fabiomaulo
Date: 2010-07-28 21:42:28 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Generalized IHqlGeneratorForType
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs
trunk/nhibernate/src/NHibernate/Linq/Functions/IHqlGeneratorForType.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs 2010-07-28 21:35:11 UTC (rev 5076)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs 2010-07-28 21:42:28 UTC (rev 5077)
@@ -1,42 +1,45 @@
using System;
using System.Collections.Generic;
using System.Reflection;
-using NHibernate.Linq.Visitors;
namespace NHibernate.Linq.Functions
{
- abstract public class BaseHqlGeneratorForType : IHqlGeneratorForType
- {
- protected readonly List<IHqlGeneratorForMethod> MethodRegistry = new List<IHqlGeneratorForMethod>();
- protected readonly List<IHqlGeneratorForProperty> PropertyRegistry = new List<IHqlGeneratorForProperty>();
+ public abstract class BaseHqlGeneratorForType : IHqlGeneratorForType
+ {
+ protected readonly List<IHqlGeneratorForMethod> MethodRegistry = new List<IHqlGeneratorForMethod>();
+ protected readonly List<IHqlGeneratorForProperty> PropertyRegistry = new List<IHqlGeneratorForProperty>();
- public void Register(DefaultLinqToHqlGeneratorsRegistry functionRegistry)
- {
- foreach (var generator in MethodRegistry)
- {
- foreach (var method in generator.SupportedMethods)
- {
- functionRegistry.RegisterGenerator(method, generator);
- }
- }
+ #region IHqlGeneratorForType Members
- foreach (var generator in PropertyRegistry)
- {
- foreach (var property in generator.SupportedProperties)
- {
- functionRegistry.RegisterGenerator(property, generator);
- }
- }
- }
+ public void Register(ILinqToHqlGeneratorsRegistry functionRegistry)
+ {
+ foreach (IHqlGeneratorForMethod generator in MethodRegistry)
+ {
+ foreach (MethodInfo method in generator.SupportedMethods)
+ {
+ functionRegistry.RegisterGenerator(method, generator);
+ }
+ }
- public virtual bool SupportsMethod(MethodInfo method)
- {
- return false;
- }
+ foreach (IHqlGeneratorForProperty generator in PropertyRegistry)
+ {
+ foreach (MemberInfo property in generator.SupportedProperties)
+ {
+ functionRegistry.RegisterGenerator(property, generator);
+ }
+ }
+ }
- public virtual IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method)
- {
- throw new NotSupportedException();
- }
- }
+ public virtual bool SupportsMethod(MethodInfo method)
+ {
+ return false;
+ }
+
+ public virtual IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method)
+ {
+ throw new NotSupportedException();
+ }
+
+ #endregion
+ }
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/IHqlGeneratorForType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/IHqlGeneratorForType.cs 2010-07-28 21:35:11 UTC (rev 5076)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/IHqlGeneratorForType.cs 2010-07-28 21:42:28 UTC (rev 5077)
@@ -2,10 +2,10 @@
namespace NHibernate.Linq.Functions
{
- public interface IHqlGeneratorForType
- {
- void Register(DefaultLinqToHqlGeneratorsRegistry functionRegistry);
- bool SupportsMethod(MethodInfo method);
- IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method);
- }
+ public interface IHqlGeneratorForType
+ {
+ void Register(ILinqToHqlGeneratorsRegistry functionRegistry);
+ bool SupportsMethod(MethodInfo method);
+ IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method);
+ }
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 21:35:17
|
Revision: 5076
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5076&view=rev
Author: fabiomaulo
Date: 2010-07-28 21:35:11 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Relax of DefaultLinqToHqlGeneratorsRegistry
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs 2010-07-28 21:19:47 UTC (rev 5075)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs 2010-07-28 21:35:11 UTC (rev 5076)
@@ -23,7 +23,7 @@
Register(new ICollectionGenerator());
}
- private bool GetMethodGeneratorForType(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
+ protected bool GetMethodGeneratorForType(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
{
methodGenerator = null;
@@ -35,7 +35,7 @@
return false;
}
- private bool GetStandardLinqExtensionMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
+ protected bool GetStandardLinqExtensionMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
{
methodGenerator = null;
@@ -50,7 +50,7 @@
return false;
}
- private bool GetRegisteredMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
+ protected bool GetRegisteredMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
{
if (registeredMethods.TryGetValue(method, out methodGenerator))
{
@@ -59,7 +59,7 @@
return false;
}
- public bool TryGetGenerator(MethodInfo method, out IHqlGeneratorForMethod generator)
+ public virtual bool TryGetGenerator(MethodInfo method, out IHqlGeneratorForMethod generator)
{
if (method.IsGenericMethod)
{
@@ -77,22 +77,22 @@
return false;
}
- public bool TryGetGenerator(MemberInfo property, out IHqlGeneratorForProperty generator)
+ public virtual bool TryGetGenerator(MemberInfo property, out IHqlGeneratorForProperty generator)
{
return registeredProperties.TryGetValue(property, out generator);
}
- public void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator)
+ public virtual void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator)
{
registeredMethods.Add(method, generator);
}
- public void RegisterGenerator(MemberInfo property, IHqlGeneratorForProperty generator)
+ public virtual void RegisterGenerator(MemberInfo property, IHqlGeneratorForProperty generator)
{
registeredProperties.Add(property, generator);
}
- private void Register(IHqlGeneratorForType typeMethodGenerator)
+ protected void Register(IHqlGeneratorForType typeMethodGenerator)
{
typeGenerators.Add(typeMethodGenerator);
typeMethodGenerator.Register(this);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 21:19:54
|
Revision: 5075
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5075&view=rev
Author: fabiomaulo
Date: 2010-07-28 21:19:47 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Refactoring (class renaming)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs
trunk/nhibernate/src/NHibernate/Linq/Functions/IHqlGeneratorForType.cs
trunk/nhibernate/src/NHibernate/Linq/Functions/LinqToHqlGeneratorsRegistryFactory.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs
trunk/nhibernate/src/NHibernate.Test/Linq/LinqToHqlGeneratorsRegistryFactoryTest.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs 2010-07-28 21:15:15 UTC (rev 5074)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs 2010-07-28 21:19:47 UTC (rev 5075)
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Reflection;
using NHibernate.Linq.Visitors;
@@ -10,7 +10,7 @@
protected readonly List<IHqlGeneratorForMethod> MethodRegistry = new List<IHqlGeneratorForMethod>();
protected readonly List<IHqlGeneratorForProperty> PropertyRegistry = new List<IHqlGeneratorForProperty>();
- public void Register(FunctionRegistry functionRegistry)
+ public void Register(DefaultLinqToHqlGeneratorsRegistry functionRegistry)
{
foreach (var generator in MethodRegistry)
{
Copied: trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs (from rev 5070, trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs 2010-07-28 21:19:47 UTC (rev 5075)
@@ -0,0 +1,133 @@
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using NHibernate.Hql.Ast;
+using NHibernate.Linq.Visitors;
+
+namespace NHibernate.Linq.Functions
+{
+ public class DefaultLinqToHqlGeneratorsRegistry : ILinqToHqlGeneratorsRegistry
+ {
+ private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>();
+ private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>();
+ private readonly List<IHqlGeneratorForType> typeGenerators = new List<IHqlGeneratorForType>();
+
+ public DefaultLinqToHqlGeneratorsRegistry()
+ {
+ // TODO - could use reflection here
+ Register(new QueryableGenerator());
+ Register(new StringGenerator());
+ Register(new DateTimeGenerator());
+ Register(new ICollectionGenerator());
+ }
+
+ private bool GetMethodGeneratorForType(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
+ {
+ methodGenerator = null;
+
+ foreach (var typeGenerator in typeGenerators.Where(typeGenerator => typeGenerator.SupportsMethod(method)))
+ {
+ methodGenerator = typeGenerator.GetMethodGenerator(method);
+ return true;
+ }
+ return false;
+ }
+
+ private bool GetStandardLinqExtensionMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
+ {
+ methodGenerator = null;
+
+ var attr = method.GetCustomAttributes(typeof(LinqExtensionMethodAttribute), false);
+
+ if (attr.Length == 1)
+ {
+ // It is
+ methodGenerator = new HqlGeneratorForExtensionMethod((LinqExtensionMethodAttribute)attr[0], method);
+ return true;
+ }
+ return false;
+ }
+
+ private bool GetRegisteredMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
+ {
+ if (registeredMethods.TryGetValue(method, out methodGenerator))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public bool TryGetGenerator(MethodInfo method, out IHqlGeneratorForMethod generator)
+ {
+ if (method.IsGenericMethod)
+ {
+ method = method.GetGenericMethodDefinition();
+ }
+
+ if (GetRegisteredMethodGenerator(method, out generator)) return true;
+
+ // No method generator registered. Look to see if it's a standard LinqExtensionMethod
+ if (GetStandardLinqExtensionMethodGenerator(method, out generator)) return true;
+
+ // Not that either. Let's query each type generator to see if it can handle it
+ if (GetMethodGeneratorForType(method, out generator)) return true;
+
+ return false;
+ }
+
+ public bool TryGetGenerator(MemberInfo property, out IHqlGeneratorForProperty generator)
+ {
+ return registeredProperties.TryGetValue(property, out generator);
+ }
+
+ public void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator)
+ {
+ registeredMethods.Add(method, generator);
+ }
+
+ public void RegisterGenerator(MemberInfo property, IHqlGeneratorForProperty generator)
+ {
+ registeredProperties.Add(property, generator);
+ }
+
+ private void Register(IHqlGeneratorForType typeMethodGenerator)
+ {
+ typeGenerators.Add(typeMethodGenerator);
+ typeMethodGenerator.Register(this);
+ }
+ }
+
+ public class HqlGeneratorForExtensionMethod : BaseHqlGeneratorForMethod
+ {
+ private readonly string _name;
+
+ public HqlGeneratorForExtensionMethod(LinqExtensionMethodAttribute attribute, MethodInfo method)
+ {
+ _name = string.IsNullOrEmpty(attribute.Name) ? method.Name : attribute.Name;
+ }
+
+ public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
+ {
+ var args = visitor.Visit(targetObject)
+ .Union(arguments.Select(a => visitor.Visit(a)))
+ .Cast<HqlExpression>();
+
+ return treeBuilder.MethodCall(_name, args);
+ }
+ }
+
+ static class UnionExtension
+ {
+ public static IEnumerable<HqlTreeNode> Union(this HqlTreeNode first, IEnumerable<HqlTreeNode> rest)
+ {
+ yield return first;
+
+ foreach (var x in rest)
+ {
+ yield return x;
+ }
+ }
+ }
+}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 21:15:15 UTC (rev 5074)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 21:19:47 UTC (rev 5075)
@@ -1,133 +0,0 @@
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Reflection;
-using NHibernate.Hql.Ast;
-using NHibernate.Linq.Visitors;
-
-namespace NHibernate.Linq.Functions
-{
- public class FunctionRegistry : ILinqToHqlGeneratorsRegistry
- {
- private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>();
- private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>();
- private readonly List<IHqlGeneratorForType> typeGenerators = new List<IHqlGeneratorForType>();
-
- public FunctionRegistry()
- {
- // TODO - could use reflection here
- Register(new QueryableGenerator());
- Register(new StringGenerator());
- Register(new DateTimeGenerator());
- Register(new ICollectionGenerator());
- }
-
- private bool GetMethodGeneratorForType(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
- {
- methodGenerator = null;
-
- foreach (var typeGenerator in typeGenerators.Where(typeGenerator => typeGenerator.SupportsMethod(method)))
- {
- methodGenerator = typeGenerator.GetMethodGenerator(method);
- return true;
- }
- return false;
- }
-
- private bool GetStandardLinqExtensionMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
- {
- methodGenerator = null;
-
- var attr = method.GetCustomAttributes(typeof(LinqExtensionMethodAttribute), false);
-
- if (attr.Length == 1)
- {
- // It is
- methodGenerator = new HqlGeneratorForExtensionMethod((LinqExtensionMethodAttribute)attr[0], method);
- return true;
- }
- return false;
- }
-
- private bool GetRegisteredMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
- {
- if (registeredMethods.TryGetValue(method, out methodGenerator))
- {
- return true;
- }
- return false;
- }
-
- public bool TryGetGenerator(MethodInfo method, out IHqlGeneratorForMethod generator)
- {
- if (method.IsGenericMethod)
- {
- method = method.GetGenericMethodDefinition();
- }
-
- if (GetRegisteredMethodGenerator(method, out generator)) return true;
-
- // No method generator registered. Look to see if it's a standard LinqExtensionMethod
- if (GetStandardLinqExtensionMethodGenerator(method, out generator)) return true;
-
- // Not that either. Let's query each type generator to see if it can handle it
- if (GetMethodGeneratorForType(method, out generator)) return true;
-
- return false;
- }
-
- public bool TryGetGenerator(MemberInfo property, out IHqlGeneratorForProperty generator)
- {
- return registeredProperties.TryGetValue(property, out generator);
- }
-
- public void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator)
- {
- registeredMethods.Add(method, generator);
- }
-
- public void RegisterGenerator(MemberInfo property, IHqlGeneratorForProperty generator)
- {
- registeredProperties.Add(property, generator);
- }
-
- private void Register(IHqlGeneratorForType typeMethodGenerator)
- {
- typeGenerators.Add(typeMethodGenerator);
- typeMethodGenerator.Register(this);
- }
- }
-
- public class HqlGeneratorForExtensionMethod : BaseHqlGeneratorForMethod
- {
- private readonly string _name;
-
- public HqlGeneratorForExtensionMethod(LinqExtensionMethodAttribute attribute, MethodInfo method)
- {
- _name = string.IsNullOrEmpty(attribute.Name) ? method.Name : attribute.Name;
- }
-
- public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
- {
- var args = visitor.Visit(targetObject)
- .Union(arguments.Select(a => visitor.Visit(a)))
- .Cast<HqlExpression>();
-
- return treeBuilder.MethodCall(_name, args);
- }
- }
-
- static class UnionExtension
- {
- public static IEnumerable<HqlTreeNode> Union(this HqlTreeNode first, IEnumerable<HqlTreeNode> rest)
- {
- yield return first;
-
- foreach (var x in rest)
- {
- yield return x;
- }
- }
- }
-}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/IHqlGeneratorForType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/IHqlGeneratorForType.cs 2010-07-28 21:15:15 UTC (rev 5074)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/IHqlGeneratorForType.cs 2010-07-28 21:19:47 UTC (rev 5075)
@@ -1,10 +1,10 @@
-using System.Reflection;
+using System.Reflection;
namespace NHibernate.Linq.Functions
{
public interface IHqlGeneratorForType
{
- void Register(FunctionRegistry functionRegistry);
+ void Register(DefaultLinqToHqlGeneratorsRegistry functionRegistry);
bool SupportsMethod(MethodInfo method);
IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method);
}
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/LinqToHqlGeneratorsRegistryFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/LinqToHqlGeneratorsRegistryFactory.cs 2010-07-28 21:15:15 UTC (rev 5074)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/LinqToHqlGeneratorsRegistryFactory.cs 2010-07-28 21:19:47 UTC (rev 5075)
@@ -26,7 +26,7 @@
throw new HibernateException("Could not instantiate LinqToHqlGeneratorsRegistry: " + registry, e);
}
}
- return new FunctionRegistry();
+ return new DefaultLinqToHqlGeneratorsRegistry();
}
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-07-28 21:15:15 UTC (rev 5074)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-07-28 21:19:47 UTC (rev 5075)
@@ -678,7 +678,7 @@
<Compile Include="Linq\GroupJoin\LocateGroupJoinQuerySource.cs" />
<Compile Include="Linq\GroupJoin\NonAggregatingGroupJoinRewriter.cs" />
<Compile Include="Linq\Functions\BaseHqlGeneratorForProperty.cs" />
- <Compile Include="Linq\Functions\FunctionRegistry.cs" />
+ <Compile Include="Linq\Functions\DefaultLinqToHqlGeneratorsRegistry.cs" />
<Compile Include="Linq\Functions\IHqlGeneratorForMethod.cs" />
<Compile Include="Linq\Functions\IHqlGeneratorForProperty.cs" />
<Compile Include="Linq\Functions\BaseHqlGeneratorForMethod.cs" />
Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs 2010-07-28 21:15:15 UTC (rev 5074)
+++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs 2010-07-28 21:19:47 UTC (rev 5075)
@@ -32,7 +32,7 @@
});
configure.CollectionTypeFactory<DefaultCollectionTypeFactory>();
configure.HqlQueryTranslator<ClassicQueryTranslatorFactory>();
- configure.LinqToHqlGeneratorsRegistry<FunctionRegistry>();
+ configure.LinqToHqlGeneratorsRegistry<DefaultLinqToHqlGeneratorsRegistry>();
configure.Proxy(p =>
{
p.Validation = false;
@@ -102,7 +102,7 @@
Assert.That(configure.Properties[Environment.MaxFetchDepth], Is.EqualTo("11"));
Assert.That(configure.Properties[Environment.QuerySubstitutions], Is.EqualTo("true 1, false 0, yes 'Y', no 'N'"));
Assert.That(configure.Properties[Environment.Hbm2ddlAuto], Is.EqualTo("validate"));
- configure.Properties[Environment.LinqToHqlGeneratorsRegistry].Should().Be(typeof(FunctionRegistry).AssemblyQualifiedName);
+ configure.Properties[Environment.LinqToHqlGeneratorsRegistry].Should().Be(typeof(DefaultLinqToHqlGeneratorsRegistry).AssemblyQualifiedName);
}
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/Linq/LinqToHqlGeneratorsRegistryFactoryTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Linq/LinqToHqlGeneratorsRegistryFactoryTest.cs 2010-07-28 21:15:15 UTC (rev 5074)
+++ trunk/nhibernate/src/NHibernate.Test/Linq/LinqToHqlGeneratorsRegistryFactoryTest.cs 2010-07-28 21:19:47 UTC (rev 5075)
@@ -15,7 +15,7 @@
{
var registry = LinqToHqlGeneratorsRegistryFactory.CreateGeneratorsRegistry(new Dictionary<string, string>());
registry.Should().Not.Be.Null();
- registry.Should().Be.OfType<FunctionRegistry>();
+ registry.Should().Be.OfType<DefaultLinqToHqlGeneratorsRegistry>();
}
[Test]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 21:15:21
|
Revision: 5074
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5074&view=rev
Author: fabiomaulo
Date: 2010-07-28 21:15:15 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Added the new LinqToHqlGeneratorsRegistry property configuration through Loquacious
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs
trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2010-07-28 20:57:45 UTC (rev 5073)
+++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2010-07-28 21:15:15 UTC (rev 5074)
@@ -1,5 +1,6 @@
using System;
using NHibernate.Hql;
+using NHibernate.Linq.Functions;
using NHibernate.Util;
namespace NHibernate.Cfg.Loquacious
@@ -42,6 +43,12 @@
return configuration;
}
+ public static Configuration LinqToHqlGeneratorsRegistry<TLinqToHqlGeneratorsRegistry>(this Configuration configuration) where TLinqToHqlGeneratorsRegistry : ILinqToHqlGeneratorsRegistry
+ {
+ configuration.SetProperty(Environment.LinqToHqlGeneratorsRegistry, typeof(TLinqToHqlGeneratorsRegistry).AssemblyQualifiedName);
+ return configuration;
+ }
+
public static Configuration Mappings(this Configuration configuration, Action<IMappingsConfigurationProperties> mappingsProperties)
{
mappingsProperties(new MappingsConfigurationProperties(configuration));
Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs 2010-07-28 20:57:45 UTC (rev 5073)
+++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs 2010-07-28 21:15:15 UTC (rev 5074)
@@ -4,11 +4,13 @@
using NHibernate.Dialect;
using NHibernate.Driver;
using NHibernate.Hql.Classic;
+using NHibernate.Linq.Functions;
using NHibernate.Type;
using NUnit.Framework;
using NHibernate.Cfg.Loquacious;
using System.Data;
using NHibernate.Exceptions;
+using SharpTestsEx;
namespace NHibernate.Test.CfgTest.Loquacious
{
@@ -30,6 +32,7 @@
});
configure.CollectionTypeFactory<DefaultCollectionTypeFactory>();
configure.HqlQueryTranslator<ClassicQueryTranslatorFactory>();
+ configure.LinqToHqlGeneratorsRegistry<FunctionRegistry>();
configure.Proxy(p =>
{
p.Validation = false;
@@ -99,6 +102,7 @@
Assert.That(configure.Properties[Environment.MaxFetchDepth], Is.EqualTo("11"));
Assert.That(configure.Properties[Environment.QuerySubstitutions], Is.EqualTo("true 1, false 0, yes 'Y', no 'N'"));
Assert.That(configure.Properties[Environment.Hbm2ddlAuto], Is.EqualTo("validate"));
+ configure.Properties[Environment.LinqToHqlGeneratorsRegistry].Should().Be(typeof(FunctionRegistry).AssemblyQualifiedName);
}
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ric...@us...> - 2010-07-28 20:57:52
|
Revision: 5073
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5073&view=rev
Author: ricbrown
Date: 2010-07-28 20:57:45 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Fix NH-2257 (Parameter ordering not working when driver does not support Named Parameters)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs
trunk/nhibernate/src/NHibernate/Driver/DriverBase.cs
trunk/nhibernate/src/NHibernate/Driver/IDriver.cs
trunk/nhibernate/src/NHibernate/Engine/IBatcher.cs
trunk/nhibernate/src/NHibernate/Loader/Loader.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2010-07-28 20:44:14 UTC (rev 5072)
+++ trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2010-07-28 20:57:45 UTC (rev 5073)
@@ -222,6 +222,11 @@
}
}
+ public void ExpandQueryParameters(IDbCommand cmd, SqlString sqlString)
+ {
+ Driver.ExpandQueryParameters(cmd, sqlString);
+ }
+
public IDataReader ExecuteReader(IDbCommand cmd)
{
CheckReaders();
Modified: trunk/nhibernate/src/NHibernate/Driver/DriverBase.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/DriverBase.cs 2010-07-28 20:44:14 UTC (rev 5072)
+++ trunk/nhibernate/src/NHibernate/Driver/DriverBase.cs 2010-07-28 20:57:45 UTC (rev 5073)
@@ -208,6 +208,36 @@
return dbParam;
}
+ public virtual void ExpandQueryParameters(IDbCommand cmd, SqlString sqlString)
+ {
+ if (UseNamedPrefixInSql)
+ return; // named parameters are ok
+
+ var expandedParameters = new List<IDbDataParameter>();
+ foreach (object part in sqlString.Parts)
+ {
+ if (part is Parameter)
+ {
+ var parameter = (Parameter)part;
+ var originalParameter = (IDbDataParameter)cmd.Parameters[parameter.ParameterPosition.Value];
+ expandedParameters.Add(CloneParameter(cmd, originalParameter));
+ }
+ }
+
+ cmd.Parameters.Clear();
+ foreach (var parameter in expandedParameters)
+ cmd.Parameters.Add(parameter);
+ }
+
+ protected virtual IDbDataParameter CloneParameter(IDbCommand cmd, IDbDataParameter originalParameter)
+ {
+ var clone = cmd.CreateParameter();
+ clone.DbType = originalParameter.DbType;
+ clone.ParameterName = originalParameter.ParameterName;
+ clone.Value = originalParameter.Value;
+ return clone;
+ }
+
public void PrepareCommand(IDbCommand command)
{
OnBeforePrepare(command);
Modified: trunk/nhibernate/src/NHibernate/Driver/IDriver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/IDriver.cs 2010-07-28 20:44:14 UTC (rev 5072)
+++ trunk/nhibernate/src/NHibernate/Driver/IDriver.cs 2010-07-28 20:57:45 UTC (rev 5073)
@@ -95,5 +95,16 @@
/// <param name="sqlType">The SqlType to set for IDbDataParameter.</param>
/// <returns>An IDbDataParameter ready to be added to an IDbCommand.</returns>
IDbDataParameter GenerateParameter(IDbCommand command, string name, SqlType sqlType);
+
+ /// <summary>
+ /// Expand the parameters of the cmd to have a single parameter for each parameter in the
+ /// sql string
+ /// </summary>
+ /// <remarks>
+ /// This is for databases that do not support named parameters. So, instead of a single parameter
+ /// for 'select ... from MyTable t where t.Col1 = @p0 and t.Col2 = @p0' we can issue
+ /// 'select ... from MyTable t where t.Col1 = ? and t.Col2 = ?'
+ /// </remarks>
+ void ExpandQueryParameters(IDbCommand cmd, SqlString sqlString);
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Engine/IBatcher.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/IBatcher.cs 2010-07-28 20:44:14 UTC (rev 5072)
+++ trunk/nhibernate/src/NHibernate/Engine/IBatcher.cs 2010-07-28 20:57:45 UTC (rev 5073)
@@ -132,6 +132,17 @@
int ExecuteNonQuery(IDbCommand cmd);
/// <summary>
+ /// Expand the parameters of the cmd to have a single parameter for each parameter in the
+ /// sql string
+ /// </summary>
+ /// <remarks>
+ /// This is for databases that do not support named parameters. So, instead of a single parameter
+ /// for 'select ... from MyTable t where t.Col1 = @p0 and t.Col2 = @p0' we can issue
+ /// 'select ... from MyTable t where t.Col1 = ? and t.Col2 = ?'
+ /// </remarks>
+ void ExpandQueryParameters(IDbCommand cmd, SqlString sqlString);
+
+ /// <summary>
/// Must be called when an exception occurs.
/// </summary>
/// <param name="e"></param>
Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2010-07-28 20:44:14 UTC (rev 5072)
+++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2010-07-28 20:57:45 UTC (rev 5073)
@@ -1148,6 +1148,8 @@
BindLimitParameters(command, colIndex, selection, session);
}
+ session.Batcher.ExpandQueryParameters(command, sqlString);
+
if (!useLimit)
{
SetMaxRows(command, selection);
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257
___________________________________________________________________
Added: bugtraq:url
+ http://jira.nhibernate.org/browse/%BUGID%
Added: bugtraq:logregex
+ NH-\d+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257/Domain.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257/Domain.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257/Domain.cs 2010-07-28 20:57:45 UTC (rev 5073)
@@ -0,0 +1,11 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH2257
+{
+ public class Foo
+ {
+ public virtual int Id { get; set; }
+ public virtual string Name { get; set; }
+ public virtual int Ord { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257/Fixture.cs 2010-07-28 20:57:45 UTC (rev 5073)
@@ -0,0 +1,30 @@
+using System.Linq;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH2257
+{
+ public class Fixture : BugTestCase
+ {
+ protected override bool AppliesTo(NHibernate.Dialect.Dialect dialect)
+ {
+ return (dialect is NHibernate.Dialect.InformixDialect1000);
+ }
+
+ [Test]
+ public void InformixUsingDuplicateParameters()
+ {
+ using (var session = OpenSession())
+ using (var transaction = session.BeginTransaction())
+ {
+ session.Save(new Foo() { Name = "aa" });
+
+ var list =
+ session.CreateQuery("from Foo f where f.Name = :p1 and not f.Name <> :p1")
+ .SetParameter("p1", "aa")
+ .List<Foo>();
+
+ Assert.That(list.Count, Is.EqualTo(1));
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2257/Mappings.hbm.xml 2010-07-28 20:57:45 UTC (rev 5073)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH2257">
+
+ <class name="Foo">
+ <id name="Id">
+ <generator class="hilo" />
+ </id>
+ <property name="Name"/>
+ <property name="Ord"/>
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-28 20:44:14 UTC (rev 5072)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-28 20:57:45 UTC (rev 5073)
@@ -774,6 +774,8 @@
<Compile Include="NHSpecificTest\NH2243\Person.cs" />
<Compile Include="NHSpecificTest\NH2251\Domain.cs" />
<Compile Include="NHSpecificTest\NH2251\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH2257\Domain.cs" />
+ <Compile Include="NHSpecificTest\NH2257\Fixture.cs" />
<Compile Include="NHSpecificTest\NH473\Child.cs" />
<Compile Include="NHSpecificTest\NH473\Fixture.cs" />
<Compile Include="NHSpecificTest\NH473\Parent.cs" />
@@ -2215,6 +2217,7 @@
<EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" />
<EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH2257\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2208\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2251\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2041\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 20:44:20
|
Revision: 5072
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5072&view=rev
Author: fabiomaulo
Date: 2010-07-28 20:44:14 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Fix NH-2256
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2010-07-28 20:40:40 UTC (rev 5071)
+++ trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2010-07-28 20:44:14 UTC (rev 5072)
@@ -52,7 +52,7 @@
}
settings.Dialect = dialect;
- settings.LinqToHqlGeneratorsRegistry = new FunctionRegistry();
+ settings.LinqToHqlGeneratorsRegistry = LinqToHqlGeneratorsRegistryFactory.CreateGeneratorsRegistry(properties);
#region SQL Exception converter
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 20:40:46
|
Revision: 5071
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5071&view=rev
Author: fabiomaulo
Date: 2010-07-28 20:40:40 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Added LinqToHqlGeneratorsRegistryFactory to create Generators Registry from configuration properties and through ObjectsFactory
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/Environment.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Linq/Functions/LinqToHqlGeneratorsRegistryFactory.cs
trunk/nhibernate/src/NHibernate.Test/Linq/LinqToHqlGeneratorsRegistryFactoryTest.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/Environment.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2010-07-28 20:11:31 UTC (rev 5070)
+++ trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2010-07-28 20:40:40 UTC (rev 5071)
@@ -159,6 +159,8 @@
public const string DefaultBatchFetchSize = "default_batch_fetch_size";
public const string CollectionTypeFactoryClass = "collectiontype.factory_class";
+
+ public const string LinqToHqlGeneratorsRegistry = "linqtohql.generatorsregistry";
private static readonly Dictionary<string, string> GlobalProperties;
Added: trunk/nhibernate/src/NHibernate/Linq/Functions/LinqToHqlGeneratorsRegistryFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/LinqToHqlGeneratorsRegistryFactory.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/LinqToHqlGeneratorsRegistryFactory.cs 2010-07-28 20:40:40 UTC (rev 5071)
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using log4net;
+using NHibernate.Util;
+using Environment = NHibernate.Cfg.Environment;
+
+namespace NHibernate.Linq.Functions
+{
+ public sealed class LinqToHqlGeneratorsRegistryFactory
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof (LinqToHqlGeneratorsRegistryFactory));
+
+ public static ILinqToHqlGeneratorsRegistry CreateGeneratorsRegistry(IDictionary<string, string> properties)
+ {
+ string registry;
+ if (properties.TryGetValue(Environment.LinqToHqlGeneratorsRegistry, out registry))
+ {
+ try
+ {
+ log.Info("Initializing LinqToHqlGeneratorsRegistry: " + registry);
+ return (ILinqToHqlGeneratorsRegistry) Environment.BytecodeProvider.ObjectsFactory.CreateInstance(ReflectHelper.ClassForName(registry));
+ }
+ catch (Exception e)
+ {
+ log.Fatal("Could not instantiate LinqToHqlGeneratorsRegistry", e);
+ throw new HibernateException("Could not instantiate LinqToHqlGeneratorsRegistry: " + registry, e);
+ }
+ }
+ return new FunctionRegistry();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-07-28 20:11:31 UTC (rev 5070)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-07-28 20:40:40 UTC (rev 5071)
@@ -655,6 +655,7 @@
<Compile Include="Linq\Expressions\AggregateExpressionNode.cs" />
<Compile Include="Linq\EagerFetchingExtensionMethods.cs" />
<Compile Include="Linq\Functions\ILinqToHqlGeneratorsRegistry.cs" />
+ <Compile Include="Linq\Functions\LinqToHqlGeneratorsRegistryFactory.cs" />
<Compile Include="Linq\LinqExtensionMethodAttribute.cs" />
<Compile Include="Linq\TypeHelperExtensionMethods.cs" />
<Compile Include="Linq\Visitors\NameUnNamedParameters.cs" />
Added: trunk/nhibernate/src/NHibernate.Test/Linq/LinqToHqlGeneratorsRegistryFactoryTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Linq/LinqToHqlGeneratorsRegistryFactoryTest.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Linq/LinqToHqlGeneratorsRegistryFactoryTest.cs 2010-07-28 20:40:40 UTC (rev 5071)
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using NHibernate.Linq.Functions;
+using NUnit.Framework;
+using SharpTestsEx;
+using Environment = NHibernate.Cfg.Environment;
+
+namespace NHibernate.Test.Linq
+{
+ public class LinqToHqlGeneratorsRegistryFactoryTest
+ {
+ [Test]
+ public void WhenNotDefinedThenReturnDefaultRegistry()
+ {
+ var registry = LinqToHqlGeneratorsRegistryFactory.CreateGeneratorsRegistry(new Dictionary<string, string>());
+ registry.Should().Not.Be.Null();
+ registry.Should().Be.OfType<FunctionRegistry>();
+ }
+
+ [Test]
+ public void WhenDefinedThenReturnCustomtRegistry()
+ {
+ var properties = new Dictionary<string, string> { { Environment.LinqToHqlGeneratorsRegistry, typeof(MyLinqToHqlGeneratorsRegistry).AssemblyQualifiedName } };
+ var registry = LinqToHqlGeneratorsRegistryFactory.CreateGeneratorsRegistry(properties);
+ registry.Should().Not.Be.Null();
+ registry.Should().Be.OfType<MyLinqToHqlGeneratorsRegistry>();
+ }
+
+ private class MyLinqToHqlGeneratorsRegistry : ILinqToHqlGeneratorsRegistry
+ {
+ public bool TryGetGenerator(MethodInfo method, out IHqlGeneratorForMethod generator)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool TryGetGenerator(MemberInfo property, out IHqlGeneratorForProperty generator)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void RegisterGenerator(MemberInfo property, IHqlGeneratorForProperty generator)
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-28 20:11:31 UTC (rev 5070)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-28 20:40:40 UTC (rev 5071)
@@ -425,6 +425,7 @@
<Compile Include="Linq\LinqQuerySamples.cs" />
<Compile Include="Linq\LinqReadonlyTestsContext.cs" />
<Compile Include="Linq\LinqTestCase.cs" />
+ <Compile Include="Linq\LinqToHqlGeneratorsRegistryFactoryTest.cs" />
<Compile Include="Linq\MethodCallTests.cs" />
<Compile Include="Linq\MiscellaneousTextFixture.cs" />
<Compile Include="Linq\NorthwindDbCreator.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 20:11:37
|
Revision: 5070
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5070&view=rev
Author: fabiomaulo
Date: 2010-07-28 20:11:31 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Refactoring (removed some 'static' and pushed out the responsibility of creation of ILinqToHqlGeneratorsRegistry)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/Settings.cs
trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs
trunk/nhibernate/src/NHibernate/IQueryExpression.cs
trunk/nhibernate/src/NHibernate/Impl/ExpressionQueryImpl.cs
trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
trunk/nhibernate/src/NHibernate/Linq/NhLinqExpression.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/VisitorParameters.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/Settings.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Settings.cs 2010-07-28 19:45:24 UTC (rev 5069)
+++ trunk/nhibernate/src/NHibernate/Cfg/Settings.cs 2010-07-28 20:11:31 UTC (rev 5070)
@@ -6,6 +6,7 @@
using NHibernate.Connection;
using NHibernate.Exceptions;
using NHibernate.Hql;
+using NHibernate.Linq.Functions;
using NHibernate.Transaction;
namespace NHibernate.Cfg
@@ -119,6 +120,11 @@
public bool IsOuterJoinFetchEnabled { get; internal set; }
+ /// <summary>
+ /// Get the registry to provide Hql-Generators for known properties/methods.
+ /// </summary>
+ public ILinqToHqlGeneratorsRegistry LinqToHqlGeneratorsRegistry { get; internal set; }
+
#endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2010-07-28 19:45:24 UTC (rev 5069)
+++ trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2010-07-28 20:11:31 UTC (rev 5070)
@@ -10,6 +10,7 @@
using NHibernate.Dialect;
using NHibernate.Exceptions;
using NHibernate.Hql;
+using NHibernate.Linq.Functions;
using NHibernate.Transaction;
using NHibernate.Util;
@@ -51,6 +52,8 @@
}
settings.Dialect = dialect;
+ settings.LinqToHqlGeneratorsRegistry = new FunctionRegistry();
+
#region SQL Exception converter
ISQLExceptionConverter sqlExceptionConverter;
Modified: trunk/nhibernate/src/NHibernate/IQueryExpression.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/IQueryExpression.cs 2010-07-28 19:45:24 UTC (rev 5069)
+++ trunk/nhibernate/src/NHibernate/IQueryExpression.cs 2010-07-28 20:11:31 UTC (rev 5070)
@@ -1,13 +1,13 @@
using System.Collections.Generic;
+using NHibernate.Engine;
using NHibernate.Engine.Query;
using NHibernate.Hql.Ast.ANTLR.Tree;
-using NHibernate.Impl;
namespace NHibernate
{
public interface IQueryExpression
{
- IASTNode Translate(ISessionFactory sessionFactory);
+ IASTNode Translate(ISessionFactoryImplementor sessionFactory);
string Key { get; }
System.Type Type { get; }
IList<NamedParameterDescriptor> ParameterDescriptors { get; }
Modified: trunk/nhibernate/src/NHibernate/Impl/ExpressionQueryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/ExpressionQueryImpl.cs 2010-07-28 19:45:24 UTC (rev 5069)
+++ trunk/nhibernate/src/NHibernate/Impl/ExpressionQueryImpl.cs 2010-07-28 20:11:31 UTC (rev 5070)
@@ -150,7 +150,7 @@
ParameterDescriptors = queryExpression.ParameterDescriptors;
}
- public IASTNode Translate(ISessionFactory sessionFactory)
+ public IASTNode Translate(ISessionFactoryImplementor sessionFactory)
{
return _tree;
}
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 19:45:24 UTC (rev 5069)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 20:11:31 UTC (rev 5070)
@@ -10,13 +10,11 @@
{
public class FunctionRegistry : ILinqToHqlGeneratorsRegistry
{
- public static readonly ILinqToHqlGeneratorsRegistry Instance = new FunctionRegistry();
-
private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>();
private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>();
private readonly List<IHqlGeneratorForType> typeGenerators = new List<IHqlGeneratorForType>();
- private FunctionRegistry()
+ public FunctionRegistry()
{
// TODO - could use reflection here
Register(new QueryableGenerator());
Modified: trunk/nhibernate/src/NHibernate/Linq/NhLinqExpression.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/NhLinqExpression.cs 2010-07-28 19:45:24 UTC (rev 5069)
+++ trunk/nhibernate/src/NHibernate/Linq/NhLinqExpression.cs 2010-07-28 20:11:31 UTC (rev 5070)
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
+using NHibernate.Engine;
using NHibernate.Engine.Query;
using NHibernate.Hql.Ast.ANTLR.Tree;
using NHibernate.Linq.Visitors;
@@ -54,7 +55,7 @@
}
}
- public IASTNode Translate(ISessionFactory sessionFactory)
+ public IASTNode Translate(ISessionFactoryImplementor sessionFactory)
{
//if (_astNode == null)
{
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-07-28 19:45:24 UTC (rev 5069)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-07-28 20:11:31 UTC (rev 5070)
@@ -23,7 +23,7 @@
public HqlGeneratorExpressionTreeVisitor(VisitorParameters parameters)
{
- functionRegistry = FunctionRegistry.Instance;
+ functionRegistry = parameters.SessionFactory.Settings.LinqToHqlGeneratorsRegistry;
_parameters = parameters;
_hqlTreeBuilder = new HqlTreeBuilder();
}
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs 2010-07-28 19:45:24 UTC (rev 5069)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs 2010-07-28 20:11:31 UTC (rev 5070)
@@ -20,7 +20,7 @@
public SelectClauseVisitor(System.Type inputType, VisitorParameters parameters)
{
- functionRegistry = FunctionRegistry.Instance;
+ functionRegistry = parameters.SessionFactory.Settings.LinqToHqlGeneratorsRegistry;
_inputParameter = Expression.Parameter(inputType, "input");
_parameters = parameters;
}
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/VisitorParameters.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/VisitorParameters.cs 2010-07-28 19:45:24 UTC (rev 5069)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/VisitorParameters.cs 2010-07-28 20:11:31 UTC (rev 5070)
@@ -1,16 +1,17 @@
using System.Collections.Generic;
using System.Linq.Expressions;
+using NHibernate.Engine;
using NHibernate.Engine.Query;
namespace NHibernate.Linq.Visitors
{
public class VisitorParameters
{
- public ISessionFactory SessionFactory { get; private set; }
+ public ISessionFactoryImplementor SessionFactory { get; private set; }
public IDictionary<ConstantExpression, NamedParameter> ConstantToParameterMap { get; private set; }
public List<NamedParameterDescriptor> RequiredHqlParameters { get; private set; }
- public VisitorParameters(ISessionFactory sessionFactory, IDictionary<ConstantExpression, NamedParameter> constantToParameterMap, List<NamedParameterDescriptor> requiredHqlParameters)
+ public VisitorParameters(ISessionFactoryImplementor sessionFactory, IDictionary<ConstantExpression, NamedParameter> constantToParameterMap, List<NamedParameterDescriptor> requiredHqlParameters)
{
SessionFactory = sessionFactory;
ConstantToParameterMap = constantToParameterMap;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 19:45:31
|
Revision: 5069
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5069&view=rev
Author: fabiomaulo
Date: 2010-07-28 19:45:24 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
- Fixed the build (sorry)
- Removed unused method
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 19:38:13 UTC (rev 5068)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 19:45:24 UTC (rev 5069)
@@ -12,68 +12,55 @@
{
public static readonly ILinqToHqlGeneratorsRegistry Instance = new FunctionRegistry();
- private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>();
- private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>();
- private readonly List<IHqlGeneratorForType> typeGenerators = new List<IHqlGeneratorForType>();
+ private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>();
+ private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>();
+ private readonly List<IHqlGeneratorForType> typeGenerators = new List<IHqlGeneratorForType>();
- private FunctionRegistry()
- {
- // TODO - could use reflection here
- Register(new QueryableGenerator());
- Register(new StringGenerator());
- Register(new DateTimeGenerator());
- Register(new ICollectionGenerator());
- }
+ private FunctionRegistry()
+ {
+ // TODO - could use reflection here
+ Register(new QueryableGenerator());
+ Register(new StringGenerator());
+ Register(new DateTimeGenerator());
+ Register(new ICollectionGenerator());
+ }
- private bool GetMethodGeneratorForType(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
- {
- methodGenerator = null;
+ private bool GetMethodGeneratorForType(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
+ {
+ methodGenerator = null;
- foreach (var typeGenerator in typeGenerators.Where(typeGenerator => typeGenerator.SupportsMethod(method)))
- {
- methodGenerator = typeGenerator.GetMethodGenerator(method);
- return true;
- }
- return false;
- }
+ foreach (var typeGenerator in typeGenerators.Where(typeGenerator => typeGenerator.SupportsMethod(method)))
+ {
+ methodGenerator = typeGenerator.GetMethodGenerator(method);
+ return true;
+ }
+ return false;
+ }
- private bool GetStandardLinqExtensionMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
- {
- methodGenerator = null;
+ private bool GetStandardLinqExtensionMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
+ {
+ methodGenerator = null;
- var attr = method.GetCustomAttributes(typeof(LinqExtensionMethodAttribute), false);
+ var attr = method.GetCustomAttributes(typeof(LinqExtensionMethodAttribute), false);
- if (attr.Length == 1)
- {
- // It is
- methodGenerator = new HqlGeneratorForExtensionMethod((LinqExtensionMethodAttribute)attr[0], method);
- return true;
- }
- return false;
- }
+ if (attr.Length == 1)
+ {
+ // It is
+ methodGenerator = new HqlGeneratorForExtensionMethod((LinqExtensionMethodAttribute)attr[0], method);
+ return true;
+ }
+ return false;
+ }
- private bool GetRegisteredMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
- {
- if (registeredMethods.TryGetValue(method, out methodGenerator))
- {
- return true;
- }
- return false;
- }
+ private bool GetRegisteredMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
+ {
+ if (registeredMethods.TryGetValue(method, out methodGenerator))
+ {
+ return true;
+ }
+ return false;
+ }
- public IHqlGeneratorForProperty GetGenerator(MemberInfo member)
- {
- IHqlGeneratorForProperty propertyGenerator;
-
- if (registeredProperties.TryGetValue(member, out propertyGenerator))
- {
- return propertyGenerator;
- }
-
- // TODO - different usage pattern to method generator
- return null;
- }
-
public bool TryGetGenerator(MethodInfo method, out IHqlGeneratorForMethod generator)
{
if (method.IsGenericMethod)
@@ -98,21 +85,21 @@
}
public void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator)
- {
- registeredMethods.Add(method, generator);
- }
+ {
+ registeredMethods.Add(method, generator);
+ }
- public void RegisterGenerator(MemberInfo property, IHqlGeneratorForProperty generator)
- {
- registeredProperties.Add(property, generator);
- }
+ public void RegisterGenerator(MemberInfo property, IHqlGeneratorForProperty generator)
+ {
+ registeredProperties.Add(property, generator);
+ }
- private void Register(IHqlGeneratorForType typeMethodGenerator)
- {
- typeGenerators.Add(typeMethodGenerator);
- typeMethodGenerator.Register(this);
- }
- }
+ private void Register(IHqlGeneratorForType typeMethodGenerator)
+ {
+ typeGenerators.Add(typeMethodGenerator);
+ typeMethodGenerator.Register(this);
+ }
+ }
public class HqlGeneratorForExtensionMethod : BaseHqlGeneratorForMethod
{
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs 2010-07-28 19:38:13 UTC (rev 5068)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs 2010-07-28 19:45:24 UTC (rev 5069)
@@ -71,7 +71,7 @@
return base.VisitExpression(expression);
}
- private static bool CanBeEvaluatedInHqlSelectStatement(Expression expression)
+ private bool CanBeEvaluatedInHqlSelectStatement(Expression expression)
{
if ((expression.NodeType == ExpressionType.MemberInit) || (expression.NodeType == ExpressionType.New) || (expression.NodeType == ExpressionType.Constant))
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 19:38:19
|
Revision: 5068
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5068&view=rev
Author: fabiomaulo
Date: 2010-07-28 19:38:13 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Refactoring
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 19:23:54 UTC (rev 5067)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 19:38:13 UTC (rev 5068)
@@ -10,7 +10,7 @@
{
public class FunctionRegistry : ILinqToHqlGeneratorsRegistry
{
- public static readonly FunctionRegistry Instance = new FunctionRegistry();
+ public static readonly ILinqToHqlGeneratorsRegistry Instance = new FunctionRegistry();
private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>();
private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>();
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-07-28 19:23:54 UTC (rev 5067)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-07-28 19:38:13 UTC (rev 5068)
@@ -12,7 +12,7 @@
{
private readonly HqlTreeBuilder _hqlTreeBuilder;
private readonly VisitorParameters _parameters;
- static private readonly FunctionRegistry FunctionRegistry = FunctionRegistry.Instance;
+ private readonly ILinqToHqlGeneratorsRegistry functionRegistry;
public static HqlTreeNode Visit(Expression expression, VisitorParameters parameters)
{
@@ -23,7 +23,8 @@
public HqlGeneratorExpressionTreeVisitor(VisitorParameters parameters)
{
- _parameters = parameters;
+ functionRegistry = FunctionRegistry.Instance;
+ _parameters = parameters;
_hqlTreeBuilder = new HqlTreeBuilder();
}
@@ -352,9 +353,8 @@
// Look for "special" properties (DateTime.Month etc)
IHqlGeneratorForProperty generator;
- generator = FunctionRegistry.GetGenerator(expression.Member);
- if (generator != null)
+ if (functionRegistry.TryGetGenerator(expression.Member, out generator))
{
return generator.BuildHql(expression.Member, expression.Expression, _hqlTreeBuilder, this);
}
@@ -398,7 +398,7 @@
IHqlGeneratorForMethod generator;
var method = expression.Method;
- if (!FunctionRegistry.TryGetGenerator(method, out generator))
+ if (!functionRegistry.TryGetGenerator(method, out generator))
{
throw new NotSupportedException(method.ToString());
}
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs 2010-07-28 19:23:54 UTC (rev 5067)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs 2010-07-28 19:38:13 UTC (rev 5068)
@@ -10,7 +10,7 @@
{
public class SelectClauseVisitor : ExpressionTreeVisitor
{
- static private readonly FunctionRegistry FunctionRegistry = FunctionRegistry.Instance;
+ private readonly ILinqToHqlGeneratorsRegistry functionRegistry;
private HashSet<Expression> _hqlNodes;
private readonly ParameterExpression _inputParameter;
@@ -20,7 +20,8 @@
public SelectClauseVisitor(System.Type inputType, VisitorParameters parameters)
{
- _inputParameter = Expression.Parameter(inputType, "input");
+ functionRegistry = FunctionRegistry.Instance;
+ _inputParameter = Expression.Parameter(inputType, "input");
_parameters = parameters;
}
@@ -82,7 +83,7 @@
{
// Depends if it's in the function registry
IHqlGeneratorForMethod methodGenerator;
- if (!FunctionRegistry.TryGetGenerator(((MethodCallExpression) expression).Method, out methodGenerator))
+ if (!functionRegistry.TryGetGenerator(((MethodCallExpression) expression).Method, out methodGenerator))
{
return false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 19:24:01
|
Revision: 5067
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5067&view=rev
Author: fabiomaulo
Date: 2010-07-28 19:23:54 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Refactoring (extract interface)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Linq/Functions/ILinqToHqlGeneratorsRegistry.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 17:48:04 UTC (rev 5066)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 19:23:54 UTC (rev 5067)
@@ -1,5 +1,4 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
@@ -9,8 +8,8 @@
namespace NHibernate.Linq.Functions
{
- public class FunctionRegistry
- {
+ public class FunctionRegistry : ILinqToHqlGeneratorsRegistry
+ {
public static readonly FunctionRegistry Instance = new FunctionRegistry();
private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>();
@@ -26,36 +25,6 @@
Register(new ICollectionGenerator());
}
- public IHqlGeneratorForMethod GetGenerator(MethodInfo method)
- {
- IHqlGeneratorForMethod methodGenerator;
-
- if (!TryGetMethodGenerator(method, out methodGenerator))
- {
- throw new NotSupportedException(method.ToString());
- }
-
- return methodGenerator;
- }
-
- public bool TryGetMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
- {
- if (method.IsGenericMethod)
- {
- method = method.GetGenericMethodDefinition();
- }
-
- if (GetRegisteredMethodGenerator(method, out methodGenerator)) return true;
-
- // No method generator registered. Look to see if it's a standard LinqExtensionMethod
- if (GetStandardLinqExtensionMethodGenerator(method, out methodGenerator)) return true;
-
- // Not that either. Let's query each type generator to see if it can handle it
- if (GetMethodGeneratorForType(method, out methodGenerator)) return true;
-
- return false;
- }
-
private bool GetMethodGeneratorForType(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
{
methodGenerator = null;
@@ -105,7 +74,30 @@
return null;
}
- public void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator)
+ public bool TryGetGenerator(MethodInfo method, out IHqlGeneratorForMethod generator)
+ {
+ if (method.IsGenericMethod)
+ {
+ method = method.GetGenericMethodDefinition();
+ }
+
+ if (GetRegisteredMethodGenerator(method, out generator)) return true;
+
+ // No method generator registered. Look to see if it's a standard LinqExtensionMethod
+ if (GetStandardLinqExtensionMethodGenerator(method, out generator)) return true;
+
+ // Not that either. Let's query each type generator to see if it can handle it
+ if (GetMethodGeneratorForType(method, out generator)) return true;
+
+ return false;
+ }
+
+ public bool TryGetGenerator(MemberInfo property, out IHqlGeneratorForProperty generator)
+ {
+ return registeredProperties.TryGetValue(property, out generator);
+ }
+
+ public void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator)
{
registeredMethods.Add(method, generator);
}
Added: trunk/nhibernate/src/NHibernate/Linq/Functions/ILinqToHqlGeneratorsRegistry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/ILinqToHqlGeneratorsRegistry.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/ILinqToHqlGeneratorsRegistry.cs 2010-07-28 19:23:54 UTC (rev 5067)
@@ -0,0 +1,12 @@
+using System.Reflection;
+
+namespace NHibernate.Linq.Functions
+{
+ public interface ILinqToHqlGeneratorsRegistry
+ {
+ bool TryGetGenerator(MethodInfo method, out IHqlGeneratorForMethod generator);
+ bool TryGetGenerator(MemberInfo property, out IHqlGeneratorForProperty generator);
+ void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator);
+ void RegisterGenerator(MemberInfo property, IHqlGeneratorForProperty generator);
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-07-28 17:48:04 UTC (rev 5066)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-07-28 19:23:54 UTC (rev 5067)
@@ -351,9 +351,10 @@
}
// Look for "special" properties (DateTime.Month etc)
- var generator = FunctionRegistry.GetGenerator(expression.Member);
+ IHqlGeneratorForProperty generator;
+ generator = FunctionRegistry.GetGenerator(expression.Member);
- if (generator != null)
+ if (generator != null)
{
return generator.BuildHql(expression.Member, expression.Expression, _hqlTreeBuilder, this);
}
@@ -394,9 +395,15 @@
protected HqlTreeNode VisitMethodCallExpression(MethodCallExpression expression)
{
- var generator = FunctionRegistry.GetGenerator(expression.Method);
+ IHqlGeneratorForMethod generator;
- return generator.BuildHql(expression.Method, expression.Object, expression.Arguments, _hqlTreeBuilder, this);
+ var method = expression.Method;
+ if (!FunctionRegistry.TryGetGenerator(method, out generator))
+ {
+ throw new NotSupportedException(method.ToString());
+ }
+
+ return generator.BuildHql(method, expression.Object, expression.Arguments, _hqlTreeBuilder, this);
}
protected HqlTreeNode VisitLambdaExpression(LambdaExpression expression)
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs 2010-07-28 17:48:04 UTC (rev 5066)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs 2010-07-28 19:23:54 UTC (rev 5067)
@@ -82,7 +82,7 @@
{
// Depends if it's in the function registry
IHqlGeneratorForMethod methodGenerator;
- if (!FunctionRegistry.TryGetMethodGenerator(((MethodCallExpression) expression).Method, out methodGenerator))
+ if (!FunctionRegistry.TryGetGenerator(((MethodCallExpression) expression).Method, out methodGenerator))
{
return false;
}
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-07-28 17:48:04 UTC (rev 5066)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-07-28 19:23:54 UTC (rev 5067)
@@ -654,6 +654,7 @@
<Compile Include="Impl\SessionIdLoggingContext.cs" />
<Compile Include="Linq\Expressions\AggregateExpressionNode.cs" />
<Compile Include="Linq\EagerFetchingExtensionMethods.cs" />
+ <Compile Include="Linq\Functions\ILinqToHqlGeneratorsRegistry.cs" />
<Compile Include="Linq\LinqExtensionMethodAttribute.cs" />
<Compile Include="Linq\TypeHelperExtensionMethods.cs" />
<Compile Include="Linq\Visitors\NameUnNamedParameters.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 17:48:10
|
Revision: 5066
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5066&view=rev
Author: fabiomaulo
Date: 2010-07-28 17:48:04 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Minor (renaming)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs
trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs 2010-07-28 16:51:31 UTC (rev 5065)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs 2010-07-28 17:48:04 UTC (rev 5066)
@@ -16,7 +16,7 @@
{
foreach (var method in generator.SupportedMethods)
{
- functionRegistry.RegisterMethodGenerator(method, generator);
+ functionRegistry.RegisterGenerator(method, generator);
}
}
@@ -24,7 +24,7 @@
{
foreach (var property in generator.SupportedProperties)
{
- functionRegistry.RegisterPropertyGenerator(property, generator);
+ functionRegistry.RegisterGenerator(property, generator);
}
}
}
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 16:51:31 UTC (rev 5065)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 17:48:04 UTC (rev 5066)
@@ -13,9 +13,9 @@
{
public static readonly FunctionRegistry Instance = new FunctionRegistry();
- private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> _registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>();
- private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> _registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>();
- private readonly List<IHqlGeneratorForType> _typeGenerators = new List<IHqlGeneratorForType>();
+ private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>();
+ private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>();
+ private readonly List<IHqlGeneratorForType> typeGenerators = new List<IHqlGeneratorForType>();
private FunctionRegistry()
{
@@ -26,7 +26,7 @@
Register(new ICollectionGenerator());
}
- public IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method)
+ public IHqlGeneratorForMethod GetGenerator(MethodInfo method)
{
IHqlGeneratorForMethod methodGenerator;
@@ -60,7 +60,7 @@
{
methodGenerator = null;
- foreach (var typeGenerator in _typeGenerators.Where(typeGenerator => typeGenerator.SupportsMethod(method)))
+ foreach (var typeGenerator in typeGenerators.Where(typeGenerator => typeGenerator.SupportsMethod(method)))
{
methodGenerator = typeGenerator.GetMethodGenerator(method);
return true;
@@ -85,18 +85,18 @@
private bool GetRegisteredMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator)
{
- if (_registeredMethods.TryGetValue(method, out methodGenerator))
+ if (registeredMethods.TryGetValue(method, out methodGenerator))
{
return true;
}
return false;
}
- public IHqlGeneratorForProperty GetPropertyGenerator(MemberInfo member)
+ public IHqlGeneratorForProperty GetGenerator(MemberInfo member)
{
IHqlGeneratorForProperty propertyGenerator;
- if (_registeredProperties.TryGetValue(member, out propertyGenerator))
+ if (registeredProperties.TryGetValue(member, out propertyGenerator))
{
return propertyGenerator;
}
@@ -105,19 +105,19 @@
return null;
}
- public void RegisterMethodGenerator(MethodInfo method, IHqlGeneratorForMethod generator)
+ public void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator)
{
- _registeredMethods.Add(method, generator);
+ registeredMethods.Add(method, generator);
}
- public void RegisterPropertyGenerator(MemberInfo property, IHqlGeneratorForProperty generator)
+ public void RegisterGenerator(MemberInfo property, IHqlGeneratorForProperty generator)
{
- _registeredProperties.Add(property, generator);
+ registeredProperties.Add(property, generator);
}
private void Register(IHqlGeneratorForType typeMethodGenerator)
{
- _typeGenerators.Add(typeMethodGenerator);
+ typeGenerators.Add(typeMethodGenerator);
typeMethodGenerator.Register(this);
}
}
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-07-28 16:51:31 UTC (rev 5065)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-07-28 17:48:04 UTC (rev 5066)
@@ -351,7 +351,7 @@
}
// Look for "special" properties (DateTime.Month etc)
- var generator = FunctionRegistry.GetPropertyGenerator(expression.Member);
+ var generator = FunctionRegistry.GetGenerator(expression.Member);
if (generator != null)
{
@@ -394,7 +394,7 @@
protected HqlTreeNode VisitMethodCallExpression(MethodCallExpression expression)
{
- var generator = FunctionRegistry.GetMethodGenerator(expression.Method);
+ var generator = FunctionRegistry.GetGenerator(expression.Method);
return generator.BuildHql(expression.Method, expression.Object, expression.Arguments, _hqlTreeBuilder, this);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-28 16:51:37
|
Revision: 5065
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5065&view=rev
Author: fabiomaulo
Date: 2010-07-28 16:51:31 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Minor (moved class in its own file)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethodAttribute.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-27 20:19:40 UTC (rev 5064)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 16:51:31 UTC (rev 5065)
@@ -7,23 +7,6 @@
using NHibernate.Hql.Ast;
using NHibernate.Linq.Visitors;
-namespace NHibernate.Linq
-{
- public class LinqExtensionMethodAttribute : Attribute
- {
- public string Name { get; private set; }
-
- public LinqExtensionMethodAttribute()
- {
- }
-
- public LinqExtensionMethodAttribute(string name)
- {
- Name = name;
- }
- }
-}
-
namespace NHibernate.Linq.Functions
{
public class FunctionRegistry
Added: trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethodAttribute.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethodAttribute.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethodAttribute.cs 2010-07-28 16:51:31 UTC (rev 5065)
@@ -0,0 +1,18 @@
+using System;
+
+namespace NHibernate.Linq
+{
+ public class LinqExtensionMethodAttribute: Attribute
+ {
+ public LinqExtensionMethodAttribute()
+ {
+ }
+
+ public LinqExtensionMethodAttribute(string name)
+ {
+ Name = name;
+ }
+
+ public string Name { get; private set; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-07-27 20:19:40 UTC (rev 5064)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-07-28 16:51:31 UTC (rev 5065)
@@ -654,6 +654,7 @@
<Compile Include="Impl\SessionIdLoggingContext.cs" />
<Compile Include="Linq\Expressions\AggregateExpressionNode.cs" />
<Compile Include="Linq\EagerFetchingExtensionMethods.cs" />
+ <Compile Include="Linq\LinqExtensionMethodAttribute.cs" />
<Compile Include="Linq\TypeHelperExtensionMethods.cs" />
<Compile Include="Linq\Visitors\NameUnNamedParameters.cs" />
<Compile Include="Linq\NhRelinqQueryParser.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-27 20:19:47
|
Revision: 5064
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5064&view=rev
Author: fabiomaulo
Date: 2010-07-27 20:19:40 +0000 (Tue, 27 Jul 2010)
Log Message:
-----------
"Decoded" failing test for NH-2208
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/E1.generated.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/Filter.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/Referred.generated.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/SubOfReferred.generated.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/E1.generated.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/E1.generated.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/E1.generated.cs 2010-07-27 20:19:40 UTC (rev 5064)
@@ -0,0 +1,53 @@
+//------------------------------------------------------------------------------
+// <autogenerated>
+// This code was generated by NHibernate.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </autogenerated>
+//------------------------------------------------------------------------------
+
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH2208
+{
+ /// <summary>
+ /// a class mapping for the table: E1
+ /// </summary>
+ public partial class E1
+ {
+
+ #region private fields
+ Int32 _id;
+ String _p1;
+ SubOfReferred _bO;
+ #endregion
+
+ #region getter/setters
+ /// <summary>
+ ///
+ /// </summary>
+ public virtual Int32 Id
+ {
+ get{ return _id; }
+ set{ _id = value; }
+ }
+ /// <summary>
+ ///
+ /// </summary>
+ public virtual String P1
+ {
+ get{ return _p1; }
+ set{ _p1 = value; }
+ }
+ /// <summary>
+ ///
+ /// </summary>
+ public virtual SubOfReferred BO
+ {
+ get{ return _bO; }
+ set{ _bO = value; }
+ }
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/Filter.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/Filter.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/Filter.cs 2010-07-27 20:19:40 UTC (rev 5064)
@@ -0,0 +1,17 @@
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH2208
+{
+ public class Filter : BugTestCase
+ {
+ [Test, Ignore("Not fixed yet")]
+ public void Test()
+ {
+ using (ISession session = OpenSession())
+ {
+ session.EnableFilter("myfilter");
+ session.CreateQuery("from E1 e join fetch e.BO").List();
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/Mappings.hbm.xml 2010-07-27 20:19:40 UTC (rev 5064)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH2208">
+
+ <class name="E1" table="E1" >
+ <id name="Id" type="Int32">
+ <generator class="native"/>
+ </id>
+ <property name="P1" type="String"/>
+ <many-to-one class="SubOfReferred" name="BO"/>
+ <filter name="myfilter"/>
+ </class>
+
+ <class name="Referred" table="Referred" >
+ <id name="Id" type="Int32">
+ <generator class="native"/>
+ </id>
+ <property name="P1" type="String"></property>
+ <joined-subclass name="SubOfReferred" table="SubT1">
+ <key column="k1"/>
+ <property name="XX" type="String"/>
+ </joined-subclass>
+ <filter name="myfilter"/>
+ </class>
+ <filter-def name="myfilter" condition="P1 like '%doesnotmatter%'"/>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/Referred.generated.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/Referred.generated.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/Referred.generated.cs 2010-07-27 20:19:40 UTC (rev 5064)
@@ -0,0 +1,44 @@
+//------------------------------------------------------------------------------
+// <autogenerated>
+// This code was generated by NHibernate.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </autogenerated>
+//------------------------------------------------------------------------------
+
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH2208
+{
+ /// <summary>
+ /// a class mapping for the table: Referred
+ /// </summary>
+ public partial class Referred
+ {
+
+ #region private fields
+ Int32 _id;
+ String _p1;
+ #endregion
+
+ #region getter/setters
+ /// <summary>
+ ///
+ /// </summary>
+ public virtual Int32 Id
+ {
+ get{ return _id; }
+ set{ _id = value; }
+ }
+ /// <summary>
+ ///
+ /// </summary>
+ public virtual String P1
+ {
+ get{ return _p1; }
+ set{ _p1 = value; }
+ }
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/SubOfReferred.generated.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/SubOfReferred.generated.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2208/SubOfReferred.generated.cs 2010-07-27 20:19:40 UTC (rev 5064)
@@ -0,0 +1,35 @@
+//------------------------------------------------------------------------------
+// <autogenerated>
+// This code was generated by NHibernate.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </autogenerated>
+//------------------------------------------------------------------------------
+
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH2208
+{
+ /// <summary>
+ /// a class mapping for the table: SubT1
+ /// </summary>
+ public partial class SubOfReferred : Referred
+ {
+
+ #region private fields
+ String _xX;
+ #endregion
+
+ #region getter/setters
+ /// <summary>
+ ///
+ /// </summary>
+ public virtual String XX
+ {
+ get{ return _xX; }
+ set{ _xX = value; }
+ }
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-27 18:36:09 UTC (rev 5063)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-27 20:19:40 UTC (rev 5064)
@@ -758,6 +758,10 @@
<Compile Include="NHSpecificTest\NH2201\Model.cs" />
<Compile Include="NHSpecificTest\NH2207\DomainClass.cs" />
<Compile Include="NHSpecificTest\NH2207\SampleTest.cs" />
+ <Compile Include="NHSpecificTest\NH2208\E1.generated.cs" />
+ <Compile Include="NHSpecificTest\NH2208\Filter.cs" />
+ <Compile Include="NHSpecificTest\NH2208\Referred.generated.cs" />
+ <Compile Include="NHSpecificTest\NH2208\SubOfReferred.generated.cs" />
<Compile Include="NHSpecificTest\NH2230\Domain.cs" />
<Compile Include="NHSpecificTest\NH2230\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2234\Fixture.cs" />
@@ -2210,6 +2214,7 @@
<EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" />
<EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH2208\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2251\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2041\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2031\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-27 18:36:15
|
Revision: 5063
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5063&view=rev
Author: fabiomaulo
Date: 2010-07-27 18:36:09 +0000 (Tue, 27 Jul 2010)
Log Message:
-----------
SchemaUpdate supporting auto-quote configuration (end Fix NH-2253)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs
trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs 2010-07-27 17:52:03 UTC (rev 5062)
+++ trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs 2010-07-27 18:36:09 UTC (rev 5063)
@@ -139,6 +139,13 @@
{
log.Info("Running hbm2ddl schema update");
+ string autoKeyWordsImport = PropertiesHelper.GetString(Environment.Hbm2ddlKeyWords, configuration.Properties, "not-defined");
+ autoKeyWordsImport = autoKeyWordsImport.ToLowerInvariant();
+ if (autoKeyWordsImport == Hbm2DDLKeyWords.AutoQuote)
+ {
+ SchemaMetadataUpdater.QuoteTableAndColumns(configuration);
+ }
+
DbConnection connection;
IDbCommand stmt = null;
Modified: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs 2010-07-27 17:52:03 UTC (rev 5062)
+++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs 2010-07-27 18:36:09 UTC (rev 5063)
@@ -1,6 +1,10 @@
+using System.Collections.Generic;
+using System.Linq;
using System.Text;
using NHibernate.Cfg;
using NHibernate.Dialect;
+using NHibernate.Mapping;
+using NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest;
using NHibernate.Tool.hbm2ddl;
using NUnit.Framework;
using SharpTestsEx;
@@ -27,5 +31,32 @@
new SchemaExport(configuration).Execute(s=> script.AppendLine(s), false, false);
script.ToString().Should().Contain("[Order]").And.Contain("[Select]").And.Contain("[From]").And.Contain("[And]");
}
+
+ [Test]
+ public void WhenUpdateCalledExplicitlyThenTakeInAccountHbm2DdlKeyWordsSetting()
+ {
+ var configuration = TestConfigurationHelper.GetDefaultConfiguration();
+ var dialect = NHibernate.Dialect.Dialect.GetDialect(configuration.Properties);
+ if (!(dialect is MsSql2000Dialect))
+ {
+ Assert.Ignore(GetType() + " does not apply to " + dialect);
+ }
+
+ configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote");
+ configuration.AddResource("NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest.HeavyEntity.hbm.xml",
+ GetType().Assembly);
+
+ var script = new StringBuilder();
+ new Tool.hbm2ddl.SchemaUpdate(configuration).Execute(s => script.AppendLine(s), false);
+
+ // With SchemaUpdate the auto-quote method should be called and the conf. should hold quoted stuff
+ var cm = configuration.GetClassMapping(typeof(Order));
+ var culs = cm.Table.ColumnIterator.ToList();
+ cm.Table.Satisfy(t=> t.IsQuoted);
+ culs.First(c => "From".Equals(c.Name)).Satisfy(c=> c.IsQuoted);
+ culs.First(c => "And".Equals(c.Name)).Satisfy(c => c.IsQuoted);
+ culs.First(c => "Select".Equals(c.Name)).Satisfy(c => c.IsQuoted);
+ culs.First(c => "Column".Equals(c.Name)).Satisfy(c => c.IsQuoted);
+ }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-27 17:52:10
|
Revision: 5062
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5062&view=rev
Author: fabiomaulo
Date: 2010-07-27 17:52:03 +0000 (Tue, 27 Jul 2010)
Log Message:
-----------
SchemaExport supporting auto-quote configuration
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs 2010-07-27 17:08:22 UTC (rev 5061)
+++ trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs 2010-07-27 17:52:03 UTC (rev 5062)
@@ -55,6 +55,13 @@
{
return;
}
+ string autoKeyWordsImport = PropertiesHelper.GetString(Environment.Hbm2ddlKeyWords, configProperties, "not-defined");
+ autoKeyWordsImport = autoKeyWordsImport.ToLowerInvariant();
+ if (autoKeyWordsImport == Hbm2DDLKeyWords.AutoQuote)
+ {
+ SchemaMetadataUpdater.QuoteTableAndColumns(cfg);
+ }
+
dialect = Dialect.Dialect.GetDialect(configProperties);
dropSQL = cfg.GenerateDropSchemaScript(dialect);
createSQL = cfg.GenerateSchemaCreationScript(dialect);
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-27 17:08:22 UTC (rev 5061)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-27 17:52:03 UTC (rev 5062)
@@ -1434,6 +1434,7 @@
<Compile Include="SqlTest\SqlTypeFactoryFixture.cs" />
<Compile Include="Stateless\Naturalness.cs" />
<Compile Include="Stateless\StatelessWithRelationsFixture.cs" />
+ <Compile Include="Tools\hbm2ddl\SchemaExportTests\AutoQuoteFixture.cs" />
<Compile Include="Tools\hbm2ddl\SchemaExportTests\WithColumnTag.cs" />
<Compile Include="Tools\hbm2ddl\SchemaExportTests\WithColumnTagFixture.cs" />
<Compile Include="Tools\hbm2ddl\SchemaMetadataUpdaterTest\HeavyEntity.cs" />
Added: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs 2010-07-27 17:52:03 UTC (rev 5062)
@@ -0,0 +1,31 @@
+using System.Text;
+using NHibernate.Cfg;
+using NHibernate.Dialect;
+using NHibernate.Tool.hbm2ddl;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.Tools.hbm2ddl.SchemaExportTests
+{
+ public class AutoQuoteFixture
+ {
+ [Test]
+ public void WhenCalledExplicitlyThenTakeInAccountHbm2DdlKeyWordsSetting()
+ {
+ var configuration = TestConfigurationHelper.GetDefaultConfiguration();
+ var dialect = NHibernate.Dialect.Dialect.GetDialect(configuration.Properties);
+ if(!(dialect is MsSql2000Dialect))
+ {
+ Assert.Ignore(GetType() + " does not apply to " + dialect);
+ }
+
+ configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote");
+ configuration.AddResource("NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest.HeavyEntity.hbm.xml",
+ GetType().Assembly);
+
+ var script = new StringBuilder();
+ new SchemaExport(configuration).Execute(s=> script.AppendLine(s), false, false);
+ script.ToString().Should().Contain("[Order]").And.Contain("[Select]").And.Contain("[From]").And.Contain("[And]");
+ }
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-27 17:08:29
|
Revision: 5061
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5061&view=rev
Author: fabiomaulo
Date: 2010-07-27 17:08:22 +0000 (Tue, 27 Jul 2010)
Log Message:
-----------
Refactoring (lazy initialization of private fields)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs
Modified: trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs 2010-07-26 09:30:53 UTC (rev 5060)
+++ trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs 2010-07-27 17:08:22 UTC (rev 5061)
@@ -21,13 +21,15 @@
public class SchemaExport
{
private static readonly ILog log = LogManager.GetLogger(typeof (SchemaExport));
+ private bool wasInitialized;
+ private readonly Configuration cfg;
private readonly IDictionary<string, string> configProperties;
- private readonly string[] createSQL;
- private readonly Dialect.Dialect dialect;
- private readonly string[] dropSQL;
+ private string[] createSQL;
+ private Dialect.Dialect dialect;
+ private string[] dropSQL;
+ private IFormatter formatter;
private string delimiter;
private string outputFile;
- private readonly IFormatter formatter;
/// <summary>
/// Create a schema exported for a given Configuration
@@ -43,11 +45,21 @@
/// <param name="configProperties">The Properties to use when connecting to the Database.</param>
public SchemaExport(Configuration cfg, IDictionary<string, string> configProperties)
{
+ this.cfg = cfg;
this.configProperties = configProperties;
+ }
+
+ private void Initialize()
+ {
+ if(wasInitialized)
+ {
+ return;
+ }
dialect = Dialect.Dialect.GetDialect(configProperties);
dropSQL = cfg.GenerateDropSchemaScript(dialect);
createSQL = cfg.GenerateSchemaCreationScript(dialect);
formatter = (PropertiesHelper.GetBoolean(Environment.FormatSql, configProperties, true) ? FormatStyle.Ddl : FormatStyle.None).Formatter;
+ wasInitialized = true;
}
/// <summary>
@@ -108,6 +120,7 @@
private void Execute(Action<string> scriptAction, bool export, bool throwOnError, TextWriter exportOutput,
IDbCommand statement, string sql)
{
+ Initialize();
try
{
string formatted = formatter.Format(sql);
@@ -196,6 +209,7 @@
public void Execute(Action<string> scriptAction, bool export, bool justDrop, IDbConnection connection,
TextWriter exportOutput)
{
+ Initialize();
IDbCommand statement = null;
if (export && connection == null)
@@ -272,6 +286,7 @@
public void Execute(Action<string> scriptAction, bool export, bool justDrop)
{
+ Initialize();
IDbConnection connection = null;
StreamWriter fileOutput = null;
IConnectionProvider connectionProvider = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aye...@us...> - 2010-07-26 09:31:02
|
Revision: 5060
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5060&view=rev
Author: ayenderahien
Date: 2010-07-26 09:30:53 +0000 (Mon, 26 Jul 2010)
Log Message:
-----------
Adding a way to reset the Any cached type, useful if user is programatically modifying the Any instance
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/Any.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/Any.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/Any.cs 2010-07-24 12:25:11 UTC (rev 5059)
+++ trunk/nhibernate/src/NHibernate/Mapping/Any.cs 2010-07-26 09:30:53 UTC (rev 5060)
@@ -48,6 +48,13 @@
}
}
+ public void ResetCachedType()
+ {
+ // this is required if the user is programatically modifying the Any instance
+ // and need to reset the cached type instance;
+ type = null;
+ }
+
public override void SetTypeUsingReflection(string className, string propertyName, string access)
{
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-24 12:25:17
|
Revision: 5059
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5059&view=rev
Author: fabiomaulo
Date: 2010-07-24 12:25:11 +0000 (Sat, 24 Jul 2010)
Log Message:
-----------
Actualization of releasenotes of NH3.0.0Alpha1 (sorry for delay)
Modified Paths:
--------------
trunk/nhibernate/releasenotes.txt
Modified: trunk/nhibernate/releasenotes.txt
===================================================================
--- trunk/nhibernate/releasenotes.txt 2010-07-24 12:21:23 UTC (rev 5058)
+++ trunk/nhibernate/releasenotes.txt 2010-07-24 12:25:11 UTC (rev 5059)
@@ -4,7 +4,101 @@
##### Run time #####
* (NH-2199) - null values in maps/dictionaries are no longer silenty ignored/deleted
+Build 3.0.0.Alpha1 (rev5056)
+=============================
+** Sub-task
+ * [NH-2045] - NH 2044 Fixed
+
+** Bug
+ * [NH-892] - <many-to-one> associated by property-ref generates wrong SQL
+ * [NH-1849] - Using custom sql function "contains" causes an Antlr exception
+ * [NH-1891] - Formula - Escape characters break formula
+ * [NH-1899] - SaveOrUpdateCopy throws InvalidCastException
+ * [NH-1902] - QBE don't set the '%' wildcards when using an other matchmode than Matchmode.Exact
+ * [NH-1975] - QueryOver() on char Property yields exception
+ * [NH-1981] - Multiple SQL parameters generated for same HQL parameter
+ * [NH-1989] - Future query does not use second level cache
+ * [NH-2009] - Many-to-one fails when using property-ref against a joined property
+ * [NH-2020] - ISQLExceptionConverter does not get called if batch size enabled
+ * [NH-2027] - NH sql-query does not support calling Stored Procedures in Packages
+ * [NH-2030] - NHibernate.SqlTypes.SqlTypeFactory is not threadsafe
+ * [NH-2035] - Wrong error "ORDER BY items must appear in the select list if SELECT DISTINCT is specified."
+ * [NH-2044] - NHibernate.Criterion.Expression.Eq with chartype has a bug
+ * [NH-2047] - OracleDataClientBatchingBatcher writes misleading log messages in a different format than SqlClientBatchingBatcher
+ * [NH-2052] - CLONE -Getting identifier on a proxied class initializes it when identifier is defined in parent class
+ * [NH-2064] - Filter definitions should not be mandatory to be used
+ * [NH-2069] - When touching the identifier of a proxy object a call to the database is executed.
+ * [NH-2074] - SQL Server Dialect: unicode literals in formula results in incorrect SQL
+ * [NH-2086] - MsSqlCeDialect fails when mapping contains schemas
+ * [NH-2090] - ShemaValidator + Firebird
+ * [NH-2092] - Constrained lazy loaded one to one relations using Castle DynamicProxy throws ArgumentNullException
+ * [NH-2093] - When using Castle:s FieldInterceptionProxy, NHibernateProxyHelper.GuessClass() cannot guess the correct entity type.
+ * [NH-2094] - When using Castle:s FieldInterceptorProxy, accessing an initialized property (even nonlazy) throws LazyInitializationException
+ * [NH-2102] - Entity with constrained, lazy one-to-one relation should not generate field intercepting proxy
+ * [NH-2113] - NH force eager loading of key-many-to-one entity with overriden GetHashCode
+ * [NH-2122] - Nhibernate documentation refers to CriteriaUtil whitch is removed from 2.1
+ * [NH-2129] - FutureValue Parameters Missing Quotes
+ * [NH-2137] - list-index with one-to-many does not work
+ * [NH-2155] - NHibernate project files contain reference to missing AssemblyInfo.cs file
+ * [NH-2166] - Custom ISQLExceptionConverter is not called in the case when using query.UniqueResult<T>()
+ * [NH-2168] - Statistics.QueryExecutionMaxTimeQueryString is empty
+ * [NH-2173] - SetMaxResults fails when Dialect has BindLimitParametersFirst == true
+ * [NH-2175] - Cannot Cache NHibernate Future Criteria Results
+ * [NH-2189] - Fetch Join Not Consistently Working With Future
+ * [NH-2192] - Thread safety issue with QueryParameters.PrepareParameterTypes
+ * [NH-2199] - Map with element doesn't support nullable types
+ * [NH-2205] - NHibernate.Loader.Loader.DoQuery can hide exceptions
+ * [NH-2210] - Problem with merging detached entities with components
+ * [NH-2219] - HQL Update of multiple columns only updates the first column
+ * [NH-2221] - The tuplizer value specified for a component within a HBM file is ignored
+ * [NH-2225] - New Embedded LINQ Provider & Bitwise Queries
+ * [NH-2235] - IQueryOver.SelectList uses sub-type type instead of root type
+ * [NH-2242] - Formula - Escape characters break formula
+
+** Improvement
+ * [NH-1248] - Check if result of Subquery is null with Criteria API
+ * [NH-1838] - Guid support in MySql dialect
+ * [NH-1850] - NHibernate should log query duration
+ * [NH-1862] - Strongly typed configuration of SessionFactory properties
+ * [NH-1877] - Support for Projections.GroupBy(IProjection projection)
+ * [NH-1892] - Programatic configuration of Cache
+ * [NH-1935] - Add new WcfSessionContext to the already available ICurrentSessionContext implementations
+ * [NH-2021] - Exceptions serialization
+ * [NH-2055] - hbm2ddl SchemaExport support batching (GO in ddl)
+ * [NH-2065] - provide better exception details
+ * [NH-2083] - Undocumented attributes on hibernate-mapping element
+ * [NH-2150] - CreateCriteria / QueryOver inconsistency
+ * [NH-2186] - Allow MultiCriteria to directly add IQueryOver
+ * [NH-2215] - MsSql2005Dialect does not use parameters for paging parameters
+ * [NH-2216] - EnumType<T> as IType
+ * [NH-2230] - <parent> tag does not allow any accessor
+ * [NH-2249] - DateType as IParameterizedType to customize the BaseDateValue for null
+
+** New Feature
+ * [NH-429] - Lazy load columns
+ * [NH-1922] - Allow DetachedCriteria To Work with IStatelessSession
+ * [NH-1978] - Add ability to delimit aliases in generated SQL
+ * [NH-2152] - QueryOver equality to null should generate (x is null or x == value)
+
+** Patch
+ * [NH-2031] - Mod function in SqlDialect is broken
+ * [NH-2041] - SchemaExport does not export Components in Joined tables properly
+ * [NH-2046] - Release builds do not include PDB files
+ * [NH-2101] - Missing IsNotIn for WhereRestrictionOn
+ * [NH-2106] - DetachedCriteria.SetLockMode() is missing
+ * [NH-2131] - SessionIdLoggingContext perf patch
+ * [NH-2169] - ToUpper and ToLower functions are inverted in the new Linq provider
+ * [NH-2194] - NHibernate.Util.PropertiesHelper class throwing FormatException when property values are in-compatible with the expected type
+ * [NH-2201] - NDataReader doesn't reset the currentrow index when a move to NextResult is executed
+ * [NH-2227] - Missing [Serializable] attribute on ReadOnlyAccessor
+ * [NH-2236] - GetSequenceNextValString for Informix is wrong
+ * [NH-2243] - 'foreign-key' ignored in join/key
+
+** Task
+ * [NH-2013] - HQL breaking change
+ * [NH-2247] - Update FlushMode Documentation
+
Build 2.1.1.GA (rev4814)
=============================
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-24 12:21:29
|
Revision: 5058
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5058&view=rev
Author: fabiomaulo
Date: 2010-07-24 12:21:23 +0000 (Sat, 24 Jul 2010)
Log Message:
-----------
Set actual trunk to 3.0.0Alpha2
Modified Paths:
--------------
trunk/nhibernate/build-common/common.xml
Modified: trunk/nhibernate/build-common/common.xml
===================================================================
--- trunk/nhibernate/build-common/common.xml 2010-07-24 12:11:13 UTC (rev 5057)
+++ trunk/nhibernate/build-common/common.xml 2010-07-24 12:21:23 UTC (rev 5058)
@@ -84,7 +84,7 @@
effectively SP0).
-->
- <property name="project.version" value="3.0.0.Alpha1" overwrite="false" />
+ <property name="project.version" value="3.0.0.Alpha2" overwrite="false" />
<!-- Compute short project version (major.minor) using a regex -->
<regex input="${project.version}" pattern="^(?'shortversion'\d+\.\d+)" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-07-24 12:11:19
|
Revision: 5057
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5057&view=rev
Author: fabiomaulo
Date: 2010-07-24 12:11:13 +0000 (Sat, 24 Jul 2010)
Log Message:
-----------
Added Paths:
-----------
tags/3.0.0.Alpha1/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|