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: <ste...@us...> - 2010-03-17 16:26:40
|
Revision: 4960 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4960&view=rev Author: steverstrong Date: 2010-03-17 16:26:33 +0000 (Wed, 17 Mar 2010) Log Message: ----------- Fixed TestDatabaseSetup.build file Modified Paths: -------------- trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.build trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate.TestDatabaseSetup/NHibernate.TestDatabaseSetup.csproj Property Changed: ---------------- trunk/nhibernate/ trunk/nhibernate/lib/net/3.5/ trunk/nhibernate/src/ trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests/ trunk/nhibernate/src/NHibernate.TestDatabaseSetup/ Property changes on: trunk/nhibernate ___________________________________________________________________ Modified: svn:ignore - build + build output build.old Property changes on: trunk/nhibernate/lib/net/3.5 ___________________________________________________________________ Modified: svn:ignore - NHibernate.dll + NHibernate.dll Remotion.Data.Linq.pdb Property changes on: trunk/nhibernate/src ___________________________________________________________________ Modified: svn:ignore - *.suo CloverSrc _ReSharper* *.resharperoptions *.resharper.user CloverBuild Ankh.Load *.resharper ConsoleTest _UpgradeReport_Files NHibernate.userprefs NHibernate.usertasks UpgradeLog.XML UpgradeLog2.XML UpgradeLog3.XML UpgradeLog4.XML UpgradeLog5.XML UpgradeLog6.XML UpgradeLog7.XML UpgradeLog8.XML UpgradeLog9.XML NHibernate.sln.proj NHibernate.sln.AssemblySurfaceCache.user NHibernate.sln.cache .git .gitignore NHibernate.5.0.ReSharper.user + *.suo CloverSrc _ReSharper* *.resharperoptions *.resharper.user CloverBuild Ankh.Load *.resharper ConsoleTest _UpgradeReport_Files NHibernate.userprefs NHibernate.usertasks UpgradeLog.XML UpgradeLog2.XML UpgradeLog3.XML UpgradeLog4.XML UpgradeLog5.XML UpgradeLog6.XML UpgradeLog7.XML UpgradeLog8.XML UpgradeLog9.XML NHibernate.sln.proj NHibernate.sln.AssemblySurfaceCache.user NHibernate.sln.cache .git .gitignore NHibernate.5.0.ReSharper.user LocalTestRun.testrunconfig Property changes on: trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests ___________________________________________________________________ Modified: svn:ignore - obj .#* *.user *.xsx AssemblyInfo.cs hibernate.cfg.xml *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* *.xml + *.aps *.eto *.user *.xml *.xsx *resharper* .#* AssemblyInfo.cs [Bb]in [Dd]ebug [Rr]elease bin hibernate.cfg.xml obj Property changes on: trunk/nhibernate/src/NHibernate.TestDatabaseSetup ___________________________________________________________________ Added: svn:ignore + AssemblyInfo.cs bin obj Added: trunk/nhibernate/src/NHibernate.TestDatabaseSetup/NHibernate.TestDatabaseSetup.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.TestDatabaseSetup/NHibernate.TestDatabaseSetup.csproj (rev 0) +++ trunk/nhibernate/src/NHibernate.TestDatabaseSetup/NHibernate.TestDatabaseSetup.csproj 2010-03-17 16:26:33 UTC (rev 4960) @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{BEEC1564-6FB6-49F7-BBE5-8EBD2F0F6E8A}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>NHibernate.TestDatabaseSetup</RootNamespace> + <AssemblyName>NHibernate.TestDatabaseSetup</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <StartupObject> + </StartupObject> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="nunit.framework, Version=2.5.0.9122, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\net\3.5\nunit.framework.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data" /> + </ItemGroup> + <ItemGroup> + <Compile Include="TestDatabaseSetup.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + <None Include="TestDatabaseSetup.build" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\NHibernate\NHibernate.csproj"> + <Project>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</Project> + <Name>NHibernate</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <Folder Include="Properties\" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.build =================================================================== --- trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.build 2010-03-17 15:35:33 UTC (rev 4959) +++ trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.build 2010-03-17 16:26:33 UTC (rev 4960) @@ -1,5 +1,5 @@ <?xml version="1.0" ?> -<project name="NHibernate.Test" default="build" xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd"> +<project name="NHibernate.TestDatabaseSetup" default="build" xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd"> <property name="root.dir" value="../.." /> <property name="config.FileName" value="hibernate.cfg.xml" /> <include buildfile="${root.dir}/build-common/common-project.xml" /> @@ -14,15 +14,9 @@ <include name="NHibernate.dll" /> <include name="nunit.framework.dll" /> </assemblyfileset> - <resourcefileset id="project.resources" prefix="NHibernate.Test" dynamicprefix="true"> - <include name="**/*.xml" /> - <exclude name="bin/**/*.xml" /> - </resourcefileset> </target> <target name="generate-assemblyinfo" depends="init common.generate-assemblyinfo" /> <target name="build" depends="init generate-assemblyinfo common.compile-tests"> - - <if test="${file::exists(config.FileName)}"> <copy file="hibernate.cfg.xml" tofile="${bin.dir}/hibernate.cfg.xml" /> </if> Modified: trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs =================================================================== --- trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs 2010-03-17 15:35:33 UTC (rev 4959) +++ trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs 2010-03-17 16:26:33 UTC (rev 4960) @@ -1,8 +1,8 @@ using System; using NUnit.Framework; -using Sql=System.Data.SqlClient; +using System.Data.SqlClient; -namespace NHibernate.TeamCity.TestDatabaseSetup +namespace NHibernate.TestDatabaseSetup { [TestFixture] public class DatabaseSetup @@ -12,11 +12,11 @@ { var cfg = new Cfg.Configuration(); - using (var conn = new Sql.SqlConnection(cfg.Properties["connection.connection_string"])) + using (var conn = new SqlConnection(cfg.Properties["connection.connection_string"])) { conn.Open(); - using (var cmd = new Sql.SqlCommand("use master", conn)) + using (var cmd = new System.Data.SqlClient.SqlCommand("use master", conn)) { cmd.ExecuteNonQuery(); @@ -37,3 +37,5 @@ } } } + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-03-17 15:35:40
|
Revision: 4959 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4959&view=rev Author: steverstrong Date: 2010-03-17 15:35:33 +0000 (Wed, 17 Mar 2010) Log Message: ----------- Added test to drop & recreate nhibernate database Modified Paths: -------------- trunk/nhibernate/default.build trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests/TestCase.cs trunk/nhibernate/src/NHibernate.sln Added Paths: ----------- trunk/nhibernate/src/NHibernate.TestDatabaseSetup/ trunk/nhibernate/src/NHibernate.TestDatabaseSetup/App.config trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.build trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs Modified: trunk/nhibernate/default.build =================================================================== --- trunk/nhibernate/default.build 2010-03-17 14:18:03 UTC (rev 4958) +++ trunk/nhibernate/default.build 2010-03-17 15:35:33 UTC (rev 4959) @@ -23,6 +23,7 @@ <include name="Iesi.Collections/Iesi.Collections.build" /> <include name="Iesi.Collections.Test/Iesi.Collections.Test.build" /> <include name="NHibernate/NHibernate.build" /> + <include name="NHibernate.TestDatabaseSetup/TestDatabaseSetup.build" /> <include name="NHibernate.ByteCode.LinFu/ByteCode.build" /> <include name="NHibernate.ByteCode.LinFu.Tests/ByteCode.Test.build" /> <include name="NHibernate.ByteCode.Castle/ByteCode.build" /> @@ -35,6 +36,7 @@ </fileset> <fileset id="buildfiles.tests" basedir="src"> + <include name="NHibernate.TestDatabaseSetup/TestDatabaseSetup.build" /> <include name="Iesi.Collections.Test/Iesi.Collections.Test.build" /> <include name="NHibernate.ByteCode.LinFu.Tests/ByteCode.Test.build" /> <include name="NHibernate.ByteCode.Castle.Tests/ByteCode.Test.build" /> Modified: trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests/TestCase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests/TestCase.cs 2010-03-17 14:18:03 UTC (rev 4958) +++ trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests/TestCase.cs 2010-03-17 15:35:33 UTC (rev 4959) @@ -197,7 +197,6 @@ private void CreateSchema() { - new SchemaExport(cfg).Drop(OutputDdl, true); new SchemaExport(cfg).Create(OutputDdl, true); } Property changes on: trunk/nhibernate/src/NHibernate.TestDatabaseSetup ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: trunk/nhibernate/src/NHibernate.TestDatabaseSetup/App.config =================================================================== --- trunk/nhibernate/src/NHibernate.TestDatabaseSetup/App.config (rev 0) +++ trunk/nhibernate/src/NHibernate.TestDatabaseSetup/App.config 2010-03-17 15:35:33 UTC (rev 4959) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <configSections> + <section name="hibernate-configuration" + type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" /> + </configSections> + + <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> + <session-factory name="NHibernate.TestDatabaseSetup"> + <property name="connection.connection_string"> + Server=(local);initial catalog=nhibernate;Integrated Security=SSPI + </property> + </session-factory> + </hibernate-configuration> +</configuration> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.build =================================================================== --- trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.build (rev 0) +++ trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.build 2010-03-17 15:35:33 UTC (rev 4959) @@ -0,0 +1,31 @@ +<?xml version="1.0" ?> +<project name="NHibernate.Test" default="build" xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd"> + <property name="root.dir" value="../.." /> + <property name="config.FileName" value="hibernate.cfg.xml" /> + <include buildfile="${root.dir}/build-common/common-project.xml" /> + <target name="init" depends="common.init"> + <property name="assembly.description" value="Test Database Setup for NHibernate." /> + <property name="assembly.is-cls-compliant" value="true" /> + <property name="clover.instrument" value="false" /> + <assemblyfileset id="project.references" basedir="${bin.dir}"> + <include name="System.dll" /> + <include name="System.Core.dll" /> + <include name="System.Data.dll" /> + <include name="NHibernate.dll" /> + <include name="nunit.framework.dll" /> + </assemblyfileset> + <resourcefileset id="project.resources" prefix="NHibernate.Test" dynamicprefix="true"> + <include name="**/*.xml" /> + <exclude name="bin/**/*.xml" /> + </resourcefileset> + </target> + <target name="generate-assemblyinfo" depends="init common.generate-assemblyinfo" /> + <target name="build" depends="init generate-assemblyinfo common.compile-tests"> + + + <if test="${file::exists(config.FileName)}"> + <copy file="hibernate.cfg.xml" tofile="${bin.dir}/hibernate.cfg.xml" /> + </if> + </target> + <target name="test" depends="init build common.run-database-tests" /> +</project> Added: trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs =================================================================== --- trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs 2010-03-17 15:35:33 UTC (rev 4959) @@ -0,0 +1,39 @@ +using System; +using NUnit.Framework; +using Sql=System.Data.SqlClient; + +namespace NHibernate.TeamCity.TestDatabaseSetup +{ + [TestFixture] + public class DatabaseSetup + { + [Test] + public void SetupDatabase() + { + var cfg = new Cfg.Configuration(); + + using (var conn = new Sql.SqlConnection(cfg.Properties["connection.connection_string"])) + { + conn.Open(); + + using (var cmd = new Sql.SqlCommand("use master", conn)) + { + cmd.ExecuteNonQuery(); + + cmd.CommandText = "drop database nhibernate"; + + try + { + cmd.ExecuteNonQuery(); + } + catch(Exception) + { + } + + cmd.CommandText = "create database nhibernate"; + cmd.ExecuteNonQuery(); + } + } + } + } +} Modified: trunk/nhibernate/src/NHibernate.sln =================================================================== --- trunk/nhibernate/src/NHibernate.sln 2010-03-17 14:18:03 UTC (rev 4958) +++ trunk/nhibernate/src/NHibernate.sln 2010-03-17 15:35:33 UTC (rev 4959) @@ -3,6 +3,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{593DCEA7-C933-46F3-939F-D8172399AB05}" ProjectSection(SolutionItems) = preProject ..\default.build = ..\default.build + LocalTestRun.testrunconfig = LocalTestRun.testrunconfig + NHibernate.vsmdi = NHibernate.vsmdi ..\releasenotes.txt = ..\releasenotes.txt EndProjectSection EndProject @@ -22,7 +24,12 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.ByteCode.Castle.Tests", "NHibernate.ByteCode.Castle.Tests\NHibernate.ByteCode.Castle.Tests.csproj", "{4972EE96-2417-4D47-9FF1-3B1D6B1D3191}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.TestDatabaseSetup", "NHibernate.TestDatabaseSetup\NHibernate.TestDatabaseSetup.csproj", "{BEEC1564-6FB6-49F7-BBE5-8EBD2F0F6E8A}" +EndProject Global + GlobalSection(TestCaseManagementSettings) = postSolution + CategoryFile = NHibernate.vsmdi + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU @@ -60,6 +67,10 @@ {4972EE96-2417-4D47-9FF1-3B1D6B1D3191}.Debug|Any CPU.Build.0 = Debug|Any CPU {4972EE96-2417-4D47-9FF1-3B1D6B1D3191}.Release|Any CPU.ActiveCfg = Release|Any CPU {4972EE96-2417-4D47-9FF1-3B1D6B1D3191}.Release|Any CPU.Build.0 = Release|Any CPU + {BEEC1564-6FB6-49F7-BBE5-8EBD2F0F6E8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BEEC1564-6FB6-49F7-BBE5-8EBD2F0F6E8A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BEEC1564-6FB6-49F7-BBE5-8EBD2F0F6E8A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BEEC1564-6FB6-49F7-BBE5-8EBD2F0F6E8A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-03-17 14:18:10
|
Revision: 4958 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4958&view=rev Author: steverstrong Date: 2010-03-17 14:18:03 +0000 (Wed, 17 Mar 2010) Log Message: ----------- Added support for DateTime.Date in Linq query, and tweaked ByteCode test to try to resolve buggered TeamCity server Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs trunk/nhibernate/src/NHibernate/Linq/Functions/DateTimeGenerator.cs trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests/TestCase.cs trunk/nhibernate/src/NHibernate.Test/App.config trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Linq/DateTimeTests.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2010-03-17 12:41:45 UTC (rev 4957) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2010-03-17 14:18:03 UTC (rev 4958) @@ -116,7 +116,8 @@ RegisterFunction("day", new SQLFunctionTemplate(NHibernateUtil.Int32, "datepart(day, ?1)")); RegisterFunction("month", new SQLFunctionTemplate(NHibernateUtil.Int32, "datepart(month, ?1)")); RegisterFunction("year", new SQLFunctionTemplate(NHibernateUtil.Int32, "datepart(year, ?1)")); - RegisterFunction("concat", new VarArgsSQLFunction(NHibernateUtil.String, "(", "+", ")")); + RegisterFunction("date", new SQLFunctionTemplate(NHibernateUtil.Date, "dateadd(dd, 0, datediff(dd, 0, ?1))")); + RegisterFunction("concat", new VarArgsSQLFunction(NHibernateUtil.String, "(", "+", ")")); RegisterFunction("digits", new StandardSQLFunction("digits", NHibernateUtil.String)); RegisterFunction("chr", new StandardSQLFunction("chr", NHibernateUtil.Character)); RegisterFunction("upper", new StandardSQLFunction("upper")); Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/DateTimeGenerator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Functions/DateTimeGenerator.cs 2010-03-17 12:41:45 UTC (rev 4957) +++ trunk/nhibernate/src/NHibernate/Linq/Functions/DateTimeGenerator.cs 2010-03-17 14:18:03 UTC (rev 4958) @@ -25,6 +25,7 @@ ReflectionHelper.GetProperty((DateTime x) => x.Hour), ReflectionHelper.GetProperty((DateTime x) => x.Minute), ReflectionHelper.GetProperty((DateTime x) => x.Second), + ReflectionHelper.GetProperty((DateTime x) => x.Date), }; } Modified: trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests/TestCase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests/TestCase.cs 2010-03-17 12:41:45 UTC (rev 4957) +++ trunk/nhibernate/src/NHibernate.ByteCode.Castle.Tests/TestCase.cs 2010-03-17 14:18:03 UTC (rev 4958) @@ -197,7 +197,8 @@ private void CreateSchema() { - new SchemaExport(cfg).Create(OutputDdl, true); + new SchemaExport(cfg).Drop(OutputDdl, true); + new SchemaExport(cfg).Create(OutputDdl, true); } private void DropSchema() Modified: trunk/nhibernate/src/NHibernate.Test/App.config =================================================================== --- trunk/nhibernate/src/NHibernate.Test/App.config 2010-03-17 12:41:45 UTC (rev 4957) +++ trunk/nhibernate/src/NHibernate.Test/App.config 2010-03-17 14:18:03 UTC (rev 4958) @@ -126,7 +126,7 @@ </logger> <logger name="NHibernate.SQL"> - <level value="DEBUG" /> + <level value="OFF" /> </logger> <logger name="NHibernate.AdoNet.AbstractBatcher"> Added: trunk/nhibernate/src/NHibernate.Test/Linq/DateTimeTests.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/DateTimeTests.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/DateTimeTests.cs 2010-03-17 14:18:03 UTC (rev 4958) @@ -0,0 +1,50 @@ +using System; +using System.Linq; +using NUnit.Framework; + +namespace NHibernate.Test.Linq +{ + [TestFixture] + public class DateTimeTests : LinqTestCase + { + [Test] + public void CanQueryByYear() + { + var x = (from o in db.Orders + where o.OrderDate.Value.Year == 1998 + select o).ToList(); + + Assert.AreEqual(270, x.Count()); + } + + [Test] + public void CanQueryByDate() + { + var x = (from o in db.Orders + where o.OrderDate.Value.Date == new DateTime(1998, 02, 26) + select o).ToList(); + + Assert.AreEqual(6, x.Count()); + } + + [Test] + public void CanQueryByDateTime() + { + var x = (from o in db.Orders + where o.OrderDate.Value == new DateTime(1998, 02, 26) + select o).ToList(); + + Assert.AreEqual(5, x.Count()); + } + + [Test] + public void CanQueryByDateTime2() + { + var x = (from o in db.Orders + where o.OrderDate.Value == new DateTime(1998, 02, 26, 0, 1, 0) + select o).ToList(); + + Assert.AreEqual(1, x.Count()); + } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs 2010-03-17 12:41:45 UTC (rev 4957) +++ trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs 2010-03-17 14:18:03 UTC (rev 4958) @@ -1208,7 +1208,7 @@ order = new Order { OrderId = 10905, Customer = customers.Where(c => c.CompanyName == "Wellington Importadora").First(), Employee = employees.Where(e => e.LastName == "Dodsworth").First(), OrderDate = DateTime.Parse("Feb 24 1998 12:00AM"), RequiredDate = DateTime.Parse("Mar 24 1998 12:00AM"), ShippingDate = DateTime.Parse("Mar 6 1998 12:00AM"), Shipper = shippers.Where(s => s.CompanyName == "United Package").First(), Freight = 13.72M, ShippedTo = "Wellington Importadora",ShippingAddress = new Address("Rua do Mercado, 12", "Resende", "SP", "08737-363", "Brazil", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10906, Customer = customers.Where(c => c.CompanyName == "Wolski Zajazd").First(), Employee = employees.Where(e => e.LastName == "Peacock").First(), OrderDate = DateTime.Parse("Feb 25 1998 12:00AM"), RequiredDate = DateTime.Parse("Mar 11 1998 12:00AM"), ShippingDate = DateTime.Parse("Mar 3 1998 12:00AM"), Shipper = shippers.Where(s => s.CompanyName == "Federal Shipping").First(), Freight = 26.29M, ShippedTo = "Wolski Zajazd",ShippingAddress = new Address("ul. Filtrowa 68", "Warszawa", "null", "01-012", "Poland", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10907, Customer = customers.Where(c => c.CompanyName == "Spécialités du monde").First(), Employee = employees.Where(e => e.LastName == "Suyama").First(), OrderDate = DateTime.Parse("Feb 25 1998 12:00AM"), RequiredDate = DateTime.Parse("Mar 25 1998 12:00AM"), ShippingDate = DateTime.Parse("Feb 27 1998 12:00AM"), Shipper = shippers.Where(s => s.CompanyName == "Federal Shipping").First(), Freight = 9.19M, ShippedTo = "Spécialités du monde",ShippingAddress = new Address("25, rue Lauriston", "Paris", "null", "75016", "France", null, null) }; session.Insert(order); orders.Add(order); - order = new Order { OrderId = 10908, Customer = customers.Where(c => c.CompanyName == "Reggiani Caseifici").First(), Employee = employees.Where(e => e.LastName == "Peacock").First(), OrderDate = DateTime.Parse("Feb 26 1998 12:00AM"), RequiredDate = DateTime.Parse("Mar 26 1998 12:00AM"), ShippingDate = DateTime.Parse("Mar 6 1998 12:00AM"), Shipper = shippers.Where(s => s.CompanyName == "United Package").First(), Freight = 32.96M, ShippedTo = "Reggiani Caseifici",ShippingAddress = new Address("Strada Provinciale 124", "Reggio Emilia", "null", "42100", "Italy", null, null) }; session.Insert(order); orders.Add(order); + order = new Order { OrderId = 10908, Customer = customers.Where(c => c.CompanyName == "Reggiani Caseifici").First(), Employee = employees.Where(e => e.LastName == "Peacock").First(), OrderDate = DateTime.Parse("Feb 26 1998 12:01AM"), RequiredDate = DateTime.Parse("Mar 26 1998 12:00AM"), ShippingDate = DateTime.Parse("Mar 6 1998 12:00AM"), Shipper = shippers.Where(s => s.CompanyName == "United Package").First(), Freight = 32.96M, ShippedTo = "Reggiani Caseifici",ShippingAddress = new Address("Strada Provinciale 124", "Reggio Emilia", "null", "42100", "Italy", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10909, Customer = customers.Where(c => c.CompanyName == "Santé Gourmet").First(), Employee = employees.Where(e => e.LastName == "Davolio").First(), OrderDate = DateTime.Parse("Feb 26 1998 12:00AM"), RequiredDate = DateTime.Parse("Mar 26 1998 12:00AM"), ShippingDate = DateTime.Parse("Mar 10 1998 12:00AM"), Shipper = shippers.Where(s => s.CompanyName == "United Package").First(), Freight = 53.05M, ShippedTo = "Santé Gourmet",ShippingAddress = new Address("Erling Skakkes gate 78", "Stavern", "null", "4110", "Norway", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10910, Customer = customers.Where(c => c.CompanyName == "Wilman Kala").First(), Employee = employees.Where(e => e.LastName == "Davolio").First(), OrderDate = DateTime.Parse("Feb 26 1998 12:00AM"), RequiredDate = DateTime.Parse("Mar 26 1998 12:00AM"), ShippingDate = DateTime.Parse("Mar 4 1998 12:00AM"), Shipper = shippers.Where(s => s.CompanyName == "Federal Shipping").First(), Freight = 38.11M, ShippedTo = "Wilman Kala",ShippingAddress = new Address("Keskuskatu 45", "Helsinki", "null", "21240", "Finland", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10911, Customer = customers.Where(c => c.CompanyName == "Godos Cocina Típica").First(), Employee = employees.Where(e => e.LastName == "Leverling").First(), OrderDate = DateTime.Parse("Feb 26 1998 12:00AM"), RequiredDate = DateTime.Parse("Mar 26 1998 12:00AM"), ShippingDate = DateTime.Parse("Mar 5 1998 12:00AM"), Shipper = shippers.Where(s => s.CompanyName == "Speedy Express").First(), Freight = 38.19M, ShippedTo = "Godos Cocina Típica",ShippingAddress = new Address("C/ Romero, 33", "Sevilla", "null", "41101", "Spain", null, null) }; session.Insert(order); orders.Add(order); Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-03-17 12:41:45 UTC (rev 4957) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-03-17 14:18:03 UTC (rev 4958) @@ -382,6 +382,7 @@ <Compile Include="Linq\BinaryBooleanExpressionTests.cs" /> <Compile Include="Linq\BinaryExpressionOrdererTests.cs" /> <Compile Include="Linq\CollectionAssert.cs" /> + <Compile Include="Linq\DateTimeTests.cs" /> <Compile Include="Linq\DynamicQueryTests.cs" /> <Compile Include="Linq\EagerLoadTests.cs" /> <Compile Include="Linq\Entities\Address.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-03-17 12:41:52
|
Revision: 4957 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4957&view=rev Author: steverstrong Date: 2010-03-17 12:41:45 +0000 (Wed, 17 Mar 2010) Log Message: ----------- Tweaked EagerFetching extension methods so that a client no longer needs to reference re-linq Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Linq/EagerFetchingExtensionMethods.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.build trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Modified: trunk/nhibernate/src/NHibernate/Linq/EagerFetchingExtensionMethods.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/EagerFetchingExtensionMethods.cs 2010-03-15 16:06:07 UTC (rev 4956) +++ trunk/nhibernate/src/NHibernate/Linq/EagerFetchingExtensionMethods.cs 2010-03-17 12:41:45 UTC (rev 4957) @@ -3,14 +3,14 @@ using System.Linq; using System.Linq.Expressions; using System.Reflection; -using Remotion.Data.Linq.EagerFetching; +using Remotion.Data.Linq; using Remotion.Data.Linq.Utilities; namespace NHibernate.Linq { public static class EagerFetchingExtensionMethods { - public static FluentFetchRequest<TOriginating, TRelated> Fetch<TOriginating, TRelated>( + public static INhFetchRequest<TOriginating, TRelated> Fetch<TOriginating, TRelated>( this IQueryable<TOriginating> query, Expression<Func<TOriginating, TRelated>> relatedObjectSelector) { ArgumentUtility.CheckNotNull("query", query); @@ -20,7 +20,7 @@ return CreateFluentFetchRequest<TOriginating, TRelated>(methodInfo, query, relatedObjectSelector); } - public static FluentFetchRequest<TOriginating, TRelated> FetchMany<TOriginating, TRelated>( + public static INhFetchRequest<TOriginating, TRelated> FetchMany<TOriginating, TRelated>( this IQueryable<TOriginating> query, Expression<Func<TOriginating, IEnumerable<TRelated>>> relatedObjectSelector) { ArgumentUtility.CheckNotNull("query", query); @@ -30,8 +30,8 @@ return CreateFluentFetchRequest<TOriginating, TRelated>(methodInfo, query, relatedObjectSelector); } - public static FluentFetchRequest<TQueried, TRelated> ThenFetch<TQueried, TFetch, TRelated>( - this FluentFetchRequest<TQueried, TFetch> query, Expression<Func<TFetch, TRelated>> relatedObjectSelector) + public static INhFetchRequest<TQueried, TRelated> ThenFetch<TQueried, TFetch, TRelated>( + this INhFetchRequest<TQueried, TFetch> query, Expression<Func<TFetch, TRelated>> relatedObjectSelector) { ArgumentUtility.CheckNotNull("query", query); ArgumentUtility.CheckNotNull("relatedObjectSelector", relatedObjectSelector); @@ -40,8 +40,8 @@ return CreateFluentFetchRequest<TQueried, TRelated>(methodInfo, query, relatedObjectSelector); } - public static FluentFetchRequest<TQueried, TRelated> ThenFetchMany<TQueried, TFetch, TRelated>( - this FluentFetchRequest<TQueried, TFetch> query, Expression<Func<TFetch, IEnumerable<TRelated>>> relatedObjectSelector) + public static INhFetchRequest<TQueried, TRelated> ThenFetchMany<TQueried, TFetch, TRelated>( + this INhFetchRequest<TQueried, TFetch> query, Expression<Func<TFetch, IEnumerable<TRelated>>> relatedObjectSelector) { ArgumentUtility.CheckNotNull("query", query); ArgumentUtility.CheckNotNull("relatedObjectSelector", relatedObjectSelector); @@ -50,14 +50,26 @@ return CreateFluentFetchRequest<TQueried, TRelated>(methodInfo, query, relatedObjectSelector); } - private static FluentFetchRequest<TOriginating, TRelated> CreateFluentFetchRequest<TOriginating, TRelated>( + private static INhFetchRequest<TOriginating, TRelated> CreateFluentFetchRequest<TOriginating, TRelated>( MethodInfo currentFetchMethod, IQueryable<TOriginating> query, LambdaExpression relatedObjectSelector) { var queryProvider = query.Provider; // ArgumentUtility.CheckNotNullAndType<QueryProviderBase>("query.Provider", query.Provider); var callExpression = Expression.Call(currentFetchMethod, query.Expression, relatedObjectSelector); - return new FluentFetchRequest<TOriginating, TRelated>(queryProvider, callExpression); + return new NhFetchRequest<TOriginating, TRelated>(queryProvider, callExpression); } } + + public interface INhFetchRequest<TQueried, TFetch> : IOrderedQueryable<TQueried> + { + } + + public class NhFetchRequest<TQueried, TFetch> : QueryableBase<TQueried>, INhFetchRequest<TQueried, TFetch> + { + public NhFetchRequest(IQueryProvider provider, Expression expression) + : base(provider, expression) + { + } + } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.build =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.build 2010-03-15 16:06:07 UTC (rev 4956) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.build 2010-03-17 12:41:45 UTC (rev 4957) @@ -24,8 +24,7 @@ <include name="LinFu.DynamicProxy.dll" /> <include name="nunit.framework.dll" /> <include name="Antlr3.Runtime.dll" /> - <include name="Remotion.Data.Linq.dll" /> - <include name="System.Linq.Dynamic.dll" /> + <include name="System.Linq.Dynamic.dll" /> </assemblyfileset> <resourcefileset id="project.resources" prefix="NHibernate.Test" dynamicprefix="true"> <include name="**/*.xml" /> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-03-15 16:06:07 UTC (rev 4956) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-03-17 12:41:45 UTC (rev 4957) @@ -62,10 +62,6 @@ <SpecificVersion>False</SpecificVersion> <HintPath>..\..\lib\net\3.5\nunit.framework.dll</HintPath> </Reference> - <Reference Include="Remotion.Data.Linq, Version=1.13.9.2, Culture=neutral, PublicKeyToken=cab60358ab4081ea, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\lib\net\3.5\Remotion.Data.Linq.dll</HintPath> - </Reference> <Reference Include="System" /> <Reference Include="System.configuration" /> <Reference Include="System.Core"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-03-15 16:06:18
|
Revision: 4956 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4956&view=rev Author: fabiomaulo Date: 2010-03-15 16:06:07 +0000 (Mon, 15 Mar 2010) Log Message: ----------- Fix NH-2137 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ValuePropertyBinder.cs trunk/nhibernate/src/NHibernate.Test/App.config trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/ListIndex/SimpleOneToMany.cs trunk/nhibernate/src/NHibernate.Test/ListIndex/SimpleOneToMany.hbm.xml trunk/nhibernate/src/NHibernate.Test/ListIndex/SimpleOneToManyTest.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ValuePropertyBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ValuePropertyBinder.cs 2010-03-07 10:16:09 UTC (rev 4955) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ValuePropertyBinder.cs 2010-03-15 16:06:07 UTC (rev 4956) @@ -133,7 +133,7 @@ public void BindSimpleValue(HbmListIndex listIndexMapping, string propertyPath, bool isNullable) { new TypeBinder(value, Mappings).Bind(NHibernateUtil.Int32.Name); - new ColumnsBinder(value, Mappings).Bind(listIndexMapping.Columns, false, + new ColumnsBinder(value, Mappings).Bind(listIndexMapping.Columns, isNullable, () => new HbmColumn { Modified: trunk/nhibernate/src/NHibernate.Test/App.config =================================================================== --- trunk/nhibernate/src/NHibernate.Test/App.config 2010-03-07 10:16:09 UTC (rev 4955) +++ trunk/nhibernate/src/NHibernate.Test/App.config 2010-03-15 16:06:07 UTC (rev 4956) @@ -126,7 +126,7 @@ </logger> <logger name="NHibernate.SQL"> - <level value="OFF" /> + <level value="DEBUG" /> </logger> <logger name="NHibernate.AdoNet.AbstractBatcher"> Added: trunk/nhibernate/src/NHibernate.Test/ListIndex/SimpleOneToMany.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ListIndex/SimpleOneToMany.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/ListIndex/SimpleOneToMany.cs 2010-03-15 16:06:07 UTC (rev 4956) @@ -0,0 +1,21 @@ +using System.Collections.Generic; + +namespace NHibernate.Test.ListIndex +{ + public class Image + { + public virtual int Id { get; set; } + public virtual string Path { get; set; } + } + + public class Galery + { + public Galery() + { + Images = new List<Image>(); + } + public virtual int Id { get; set; } + + public virtual IList<Image> Images { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/ListIndex/SimpleOneToMany.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ListIndex/SimpleOneToMany.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/ListIndex/SimpleOneToMany.hbm.xml 2010-03-15 16:06:07 UTC (rev 4956) @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.ListIndex"> + <class name="Image"> + <id name="Id"> + <generator class="hilo"/> + </id> + <property name="Path"/> + </class> + + <class name="Galery"> + <id name="Id"> + <generator class="hilo"/> + </id> + <list name="Images" cascade="all"> + <key column="img_key"/> + <list-index column="imgIdx"/> + <one-to-many class="Image"/> + </list> + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/ListIndex/SimpleOneToManyTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ListIndex/SimpleOneToManyTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/ListIndex/SimpleOneToManyTest.cs 2010-03-15 16:06:07 UTC (rev 4956) @@ -0,0 +1,39 @@ +using System.Collections; +using NUnit.Framework; + +namespace NHibernate.Test.ListIndex +{ + [TestFixture] + public class SimpleOneToManyTest : TestCase + { + protected override IList Mappings + { + get { return new string[] { "ListIndex.SimpleOneToMany.hbm.xml" }; } + } + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + [Test] + public void ShouldIncludeTheListIdxInserting() + { + using (var s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + var galery = new Galery(); + galery.Images.Add(new Image {Path = "image01.jpg"}); + s.Persist(galery); + Assert.DoesNotThrow(tx.Commit); + } + using (var s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + s.CreateQuery("delete from Image").ExecuteUpdate(); + s.CreateQuery("delete from Galery").ExecuteUpdate(); + tx.Commit(); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-03-07 10:16:09 UTC (rev 4955) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-03-15 16:06:07 UTC (rev 4956) @@ -429,6 +429,8 @@ <Compile Include="Linq\SelectionTests.cs" /> <Compile Include="Linq\WhereSubqueryTests.cs" /> <Compile Include="Linq\WhereTests.cs" /> + <Compile Include="ListIndex\SimpleOneToMany.cs" /> + <Compile Include="ListIndex\SimpleOneToManyTest.cs" /> <Compile Include="MappingTest\NonReflectiveBinderFixture.cs" /> <Compile Include="MappingTest\Wicked.cs" /> <Compile Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Employee.cs" /> @@ -2126,6 +2128,7 @@ <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="ListIndex\SimpleOneToMany.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2113\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1981\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2074\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2010-03-07 10:16:15
|
Revision: 4955 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4955&view=rev Author: ricbrown Date: 2010-03-07 10:16:09 +0000 (Sun, 07 Mar 2010) Log Message: ----------- Added ToRowCountQuery method to interface to allow access to the query without performing execution. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2010-03-07 09:47:45 UTC (rev 4954) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2010-03-07 10:16:09 UTC (rev 4955) @@ -147,6 +147,9 @@ IList<U> IQueryOver<TRoot>.List<U>() { return List<U>(); } + IQueryOver<TRoot,TRoot> IQueryOver<TRoot>.ToRowCountQuery() + { return ToRowCountQuery(); } + int IQueryOver<TRoot>.RowCount() { return ToRowCountQuery().SingleOrDefault<int>(); } Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2010-03-07 09:47:45 UTC (rev 4954) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2010-03-07 10:16:09 UTC (rev 4955) @@ -42,9 +42,14 @@ IList<U> List<U>(); /// <summary> - /// Clones the QueryOver, removes orders and paging, projects the row-count - /// for the query and returns the Single() result + /// Clones the QueryOver, removes orders and paging, and projects the row-count + /// for the query /// </summary> + IQueryOver<TRoot,TRoot> ToRowCountQuery(); + + /// <summary> + /// Short for ToRowCountQuery().SingleOrDefault() + /// </summary> int RowCount(); /// <summary> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2010-03-07 09:47:45 UTC (rev 4954) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2010-03-07 10:16:09 UTC (rev 4955) @@ -527,6 +527,31 @@ AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual.UnderlyingCriteria); } + [Test] + public void TransformQueryOverToRowCount() + { + IQueryOver<Person> expected = + CreateTestQueryOver<Person>() + .Where(p => p.Name == "test") + .JoinQueryOver(p => p.Children) + .Where((Child c) => c.Age == 5) + .Select(Projections.RowCount()); + + IQueryOver<Person> actual = + CreateTestQueryOver<Person>() + .Where(p => p.Name == "test") + .JoinQueryOver(p => p.Children) + .Where((Child c) => c.Age == 5) + .OrderBy(c => c.Age).Asc + .Skip(20) + .Take(10); + + expected = expected.Clone(); + actual = actual.ToRowCountQuery(); + + AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual); + } + } } \ 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-03-07 09:47:51
|
Revision: 4954 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4954&view=rev Author: ricbrown Date: 2010-03-07 09:47:45 +0000 (Sun, 07 Mar 2010) Log Message: ----------- Moved QueryOverTransformer methods into the IQueryOver interface, and dropped ICloneable. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate/QueryOverTransformer.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2010-03-06 22:49:21 UTC (rev 4953) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2010-03-07 09:47:45 UTC (rev 4954) @@ -40,8 +40,6 @@ get { return new DetachedCriteria(impl, impl); } } - public abstract object Clone(); - } [Serializable] @@ -107,6 +105,28 @@ } /// <summary> + /// Clones the QueryOver, clears the orders and paging, and projects the RowCount + /// </summary> + /// <returns></returns> + public QueryOver<TRoot,TRoot> ToRowCountQuery() + { + return + Clone() + .ClearOrders() + .Skip(0) + .Take(RowSelection.NoValue) + .Select(Projections.RowCount()); + } + + /// <summary> + /// Creates an exact clone of the QueryOver + /// </summary> + public QueryOver<TRoot,TRoot> Clone() + { + return new QueryOver<TRoot,TRoot>((CriteriaImpl)criteria.Clone()); + } + + /// <summary> /// Method to allow comparison of detached query in Lambda expression /// e.g., p => p.Name == myQuery.As<string> /// </summary> @@ -127,6 +147,9 @@ IList<U> IQueryOver<TRoot>.List<U>() { return List<U>(); } + int IQueryOver<TRoot>.RowCount() + { return ToRowCountQuery().SingleOrDefault<int>(); } + TRoot IQueryOver<TRoot>.SingleOrDefault() { return SingleOrDefault(); } @@ -145,6 +168,9 @@ IFutureValue<U> IQueryOver<TRoot>.FutureValue<U>() { return FutureValue<U>(); } + IQueryOver<TRoot,TRoot> IQueryOver<TRoot>.Clone() + { return Clone(); } + } /// <summary> @@ -179,11 +205,6 @@ this.criteria = criteria; } - public override object Clone() - { - return new QueryOver<TRoot,TRoot>((CriteriaImpl)criteria.Clone()); - } - public QueryOver<TRoot,TSubType> And(Expression<Func<TSubType, bool>> expression) { return Add(expression); Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2010-03-06 22:49:21 UTC (rev 4953) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2010-03-07 09:47:45 UTC (rev 4954) @@ -22,7 +22,7 @@ /// .List(); /// </code> /// </remarks> - public interface IQueryOver<TRoot> : ICloneable + public interface IQueryOver<TRoot> { /// <summary> /// Access the underlying ICriteria @@ -42,6 +42,12 @@ IList<U> List<U>(); /// <summary> + /// Clones the QueryOver, removes orders and paging, projects the row-count + /// for the query and returns the Single() result + /// </summary> + int RowCount(); + + /// <summary> /// Convenience method to return a single instance that matches /// the query, or null if the query returns no results. /// </summary> @@ -84,6 +90,11 @@ /// </summary> IFutureValue<U> FutureValue<U>(); + /// <summary> + /// Creates an exact clone of the IQueryOver + /// </summary> + IQueryOver<TRoot,TRoot> Clone(); + } /// <summary> Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-03-06 22:49:21 UTC (rev 4953) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-03-07 09:47:45 UTC (rev 4954) @@ -830,7 +830,6 @@ <Compile Include="Hql\Ast\ANTLR\Util\NodeTraverser.cs" /> <Compile Include="Param\VersionTypeSeedParameterSpecification.cs" /> <Compile Include="Proxy\AbstractProxyFactory.cs" /> - <Compile Include="QueryOverTransformer.cs" /> <Compile Include="SqlCommand\InsertSelect.cs" /> <Compile Include="Tool\hbm2ddl\SchemaMetadataUpdater.cs" /> <Compile Include="Tool\hbm2ddl\ScriptSplitter.cs" /> Deleted: trunk/nhibernate/src/NHibernate/QueryOverTransformer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/QueryOverTransformer.cs 2010-03-06 22:49:21 UTC (rev 4953) +++ trunk/nhibernate/src/NHibernate/QueryOverTransformer.cs 2010-03-07 09:47:45 UTC (rev 4954) @@ -1,54 +0,0 @@ -using NHibernate.Criterion; -using NHibernate.Engine; -using NHibernate.Impl; - -namespace NHibernate -{ - /// <summary> - /// Transforms QueryOver queries - /// </summary> - public static class QueryOverTransformer - { - ///<summary> - /// Returns a clone of the original QueryOver, which will return the count - /// of rows that are returned by the original QueryOver query. - ///</summary> - public static QueryOver<T,T> TransformToRowCount<T>(QueryOver<T> query) - { - QueryOver<T,T> clonedQuery = (QueryOver<T,T>)query.Clone(); - return (QueryOver<T,T>)TransformToRowCount((IQueryOver<T>)clonedQuery); - } - - ///<summary> - /// Returns a clone of the original IQueryOver, which will return the count - /// of rows that are returned by the original IQueryOver query. - ///</summary> - public static IQueryOver<T,T> TransformToRowCount<T>(IQueryOver<T> query) - { - IQueryOver<T,T> clonedQuery = (IQueryOver<T,T>)query.Clone(); - - return - clonedQuery - .ClearOrders() - .Skip(0) - .Take(RowSelection.NoValue) - .Select(Projections.RowCount()); - } - - /// <summary> - /// Creates an exact clone of the IQueryOver - /// </summary> - public static IQueryOver<T,T> Clone<T>(IQueryOver<T> query) - { - return (IQueryOver<T,T>)query.Clone(); - } - - /// <summary> - /// Creates an exact clone of the QueryOver - /// </summary> - public static QueryOver<T,T> Clone<T>(QueryOver<T> query) - { - return (QueryOver<T,T>)query.Clone(); - } - } -} Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2010-03-06 22:49:21 UTC (rev 4953) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2010-03-07 09:47:45 UTC (rev 4954) @@ -262,6 +262,45 @@ } } + [Test] + public void RowCount() + { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new Person() { Name = "Name 1", Age = 1 } + .AddChild(new Child() { Nickname = "Name 1.1", Age = 1})); + + s.Save(new Person() { Name = "Name 2", Age = 2 } + .AddChild(new Child() { Nickname = "Name 2.1", Age = 3})); + + s.Save(new Person() { Name = "Name 3", Age = 3 } + .AddChild(new Child() { Nickname = "Name 3.1", Age = 2})); + + s.Save(new Person() { Name = "Name 4", Age = 4 } + .AddChild(new Child() { Nickname = "Name 4.1", Age = 4})); + + t.Commit(); + } + + using (ISession s = OpenSession()) + { + IQueryOver<Person> query = + s.QueryOver<Person>() + .JoinQueryOver(p => p.Children) + .OrderBy(c => c.Age).Desc + .Skip(2) + .Take(1); + + IList<Person> results = query.List(); + int rowCount = query.RowCount(); + + Assert.That(results.Count, Is.EqualTo(1)); + Assert.That(results[0].Name, Is.EqualTo("Name 3")); + Assert.That(rowCount, Is.EqualTo(4)); + } + } + } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2010-03-06 22:49:21 UTC (rev 4953) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2010-03-07 09:47:45 UTC (rev 4954) @@ -491,7 +491,7 @@ .Where(p => p.Name == "test") .Select(p => p.Name); - IQueryOver<Person> actual = QueryOverTransformer.Clone(expected); + IQueryOver<Person> actual = expected.Clone(); Assert.That(actual, Is.Not.SameAs(expected)); Assert.That(actual.UnderlyingCriteria, Is.Not.SameAs(expected.UnderlyingCriteria)); @@ -505,7 +505,7 @@ CreateTestQueryOver<Person>() .JoinQueryOver(p => p.Children); - IQueryOver<Person,Person> actual = QueryOverTransformer.Clone(expected); + IQueryOver<Person,Person> actual = expected.Clone(); ICriteria expectedCriteria = expected.UnderlyingCriteria.GetCriteriaByAlias("this"); @@ -520,38 +520,13 @@ .Where(p => p.Name == "test") .Select(p => p.Name); - QueryOver<Person> actual = QueryOverTransformer.Clone(expected); + QueryOver<Person> actual = expected.Clone(); Assert.That(actual, Is.Not.SameAs(expected)); Assert.That(actual.UnderlyingCriteria, Is.Not.SameAs(expected.UnderlyingCriteria)); AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual.UnderlyingCriteria); } - [Test] - public void TransformQueryOverToRowCount() - { - QueryOver<Person> expected = - QueryOver.Of<Person>() - .Where(p => p.Name == "test") - .JoinQueryOver(p => p.Children) - .Where((Child c) => c.Age == 5) - .Select(Projections.RowCount()); - - QueryOver<Person> actual = - QueryOver.Of<Person>() - .Where(p => p.Name == "test") - .JoinQueryOver(p => p.Children) - .Where((Child c) => c.Age == 5) - .OrderBy(c => c.Age).Asc - .Skip(20) - .Take(10); - - expected = QueryOverTransformer.Clone(expected); - actual = QueryOverTransformer.TransformToRowCount(actual); - - AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual); - } - } } \ 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-03-06 22:49:28
|
Revision: 4953 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4953&view=rev Author: ricbrown Date: 2010-03-06 22:49:21 +0000 (Sat, 06 Mar 2010) Log Message: ----------- Added QueryOverTransformer. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/QueryOverTransformer.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2010-03-03 17:29:11 UTC (rev 4952) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2010-03-06 22:49:21 UTC (rev 4953) @@ -12,7 +12,7 @@ { [Serializable] - public class QueryOver + public abstract class QueryOver { protected ICriteria criteria; @@ -40,10 +40,12 @@ get { return new DetachedCriteria(impl, impl); } } + public abstract object Clone(); + } [Serializable] - public class QueryOver<TRoot> : QueryOver, IQueryOver<TRoot> + public abstract class QueryOver<TRoot> : QueryOver, IQueryOver<TRoot> { private IList<TRoot> List() @@ -177,6 +179,11 @@ this.criteria = criteria; } + public override object Clone() + { + return new QueryOver<TRoot,TRoot>((CriteriaImpl)criteria.Clone()); + } + public QueryOver<TRoot,TSubType> And(Expression<Func<TSubType, bool>> expression) { return Add(expression); @@ -290,6 +297,12 @@ return new QueryOverOrderBuilder<TRoot,TSubType>(this, path); } + public QueryOver<TRoot,TSubType> ClearOrders() + { + criteria.ClearOrders(); + return this; + } + public QueryOver<TRoot,TSubType> Skip(int firstResult) { criteria.SetFirstResult(firstResult); @@ -620,6 +633,9 @@ IQueryOverOrderBuilder<TRoot,TSubType> IQueryOver<TRoot,TSubType>.ThenBy(Expression<Func<object>> path) { return new IQueryOverOrderBuilder<TRoot,TSubType>(this, path); } + IQueryOver<TRoot,TSubType> IQueryOver<TRoot, TSubType>.ClearOrders() + { return ClearOrders(); } + IQueryOver<TRoot,TSubType> IQueryOver<TRoot,TSubType>.Skip(int firstResult) { return Skip(firstResult); } Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2010-03-03 17:29:11 UTC (rev 4952) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2010-03-06 22:49:21 UTC (rev 4953) @@ -22,7 +22,7 @@ /// .List(); /// </code> /// </remarks> - public interface IQueryOver<TRoot> + public interface IQueryOver<TRoot> : ICloneable { /// <summary> /// Access the underlying ICriteria @@ -241,6 +241,11 @@ IQueryOverOrderBuilder<TRoot,TSubType> ThenBy(Expression<Func<object>> path); /// <summary> + /// Clear all orders from the query. + /// </summary> + IQueryOver<TRoot, TSubType> ClearOrders(); + + /// <summary> /// Set the first result to be retrieved /// </summary> /// <param name="firstResult"></param> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2010-03-03 17:29:11 UTC (rev 4952) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2010-03-06 22:49:21 UTC (rev 4953) @@ -460,8 +460,12 @@ projection = projectionList; } - projectionCriteria = this; - SetResultTransformer(CriteriaSpecification.Projection); + if (projection != null) + { + projectionCriteria = this; + SetResultTransformer(CriteriaSpecification.Projection); + } + return this; } Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-03-03 17:29:11 UTC (rev 4952) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-03-06 22:49:21 UTC (rev 4953) @@ -830,6 +830,7 @@ <Compile Include="Hql\Ast\ANTLR\Util\NodeTraverser.cs" /> <Compile Include="Param\VersionTypeSeedParameterSpecification.cs" /> <Compile Include="Proxy\AbstractProxyFactory.cs" /> + <Compile Include="QueryOverTransformer.cs" /> <Compile Include="SqlCommand\InsertSelect.cs" /> <Compile Include="Tool\hbm2ddl\SchemaMetadataUpdater.cs" /> <Compile Include="Tool\hbm2ddl\ScriptSplitter.cs" /> Added: trunk/nhibernate/src/NHibernate/QueryOverTransformer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/QueryOverTransformer.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/QueryOverTransformer.cs 2010-03-06 22:49:21 UTC (rev 4953) @@ -0,0 +1,54 @@ +using NHibernate.Criterion; +using NHibernate.Engine; +using NHibernate.Impl; + +namespace NHibernate +{ + /// <summary> + /// Transforms QueryOver queries + /// </summary> + public static class QueryOverTransformer + { + ///<summary> + /// Returns a clone of the original QueryOver, which will return the count + /// of rows that are returned by the original QueryOver query. + ///</summary> + public static QueryOver<T,T> TransformToRowCount<T>(QueryOver<T> query) + { + QueryOver<T,T> clonedQuery = (QueryOver<T,T>)query.Clone(); + return (QueryOver<T,T>)TransformToRowCount((IQueryOver<T>)clonedQuery); + } + + ///<summary> + /// Returns a clone of the original IQueryOver, which will return the count + /// of rows that are returned by the original IQueryOver query. + ///</summary> + public static IQueryOver<T,T> TransformToRowCount<T>(IQueryOver<T> query) + { + IQueryOver<T,T> clonedQuery = (IQueryOver<T,T>)query.Clone(); + + return + clonedQuery + .ClearOrders() + .Skip(0) + .Take(RowSelection.NoValue) + .Select(Projections.RowCount()); + } + + /// <summary> + /// Creates an exact clone of the IQueryOver + /// </summary> + public static IQueryOver<T,T> Clone<T>(IQueryOver<T> query) + { + return (IQueryOver<T,T>)query.Clone(); + } + + /// <summary> + /// Creates an exact clone of the QueryOver + /// </summary> + public static QueryOver<T,T> Clone<T>(QueryOver<T> query) + { + return (QueryOver<T,T>)query.Clone(); + } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2010-03-03 17:29:11 UTC (rev 4952) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2010-03-06 22:49:21 UTC (rev 4953) @@ -483,6 +483,75 @@ AssertCriteriaAreEqual(expected, actual); } + [Test] + public void CloneIQueryOver() + { + IQueryOver<Person> expected = + CreateTestQueryOver<Person>() + .Where(p => p.Name == "test") + .Select(p => p.Name); + + IQueryOver<Person> actual = QueryOverTransformer.Clone(expected); + + Assert.That(actual, Is.Not.SameAs(expected)); + Assert.That(actual.UnderlyingCriteria, Is.Not.SameAs(expected.UnderlyingCriteria)); + AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual.UnderlyingCriteria); + } + + [Test] + public void CloneIQueryOverWithSubType() + { + IQueryOver<Person,Child> expected = + CreateTestQueryOver<Person>() + .JoinQueryOver(p => p.Children); + + IQueryOver<Person,Person> actual = QueryOverTransformer.Clone(expected); + + ICriteria expectedCriteria = expected.UnderlyingCriteria.GetCriteriaByAlias("this"); + + AssertCriteriaAreEqual(expectedCriteria, actual); + } + + [Test] + public void CloneQueryOver() + { + QueryOver<Person> expected = + QueryOver.Of<Person>() + .Where(p => p.Name == "test") + .Select(p => p.Name); + + QueryOver<Person> actual = QueryOverTransformer.Clone(expected); + + Assert.That(actual, Is.Not.SameAs(expected)); + Assert.That(actual.UnderlyingCriteria, Is.Not.SameAs(expected.UnderlyingCriteria)); + AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual.UnderlyingCriteria); + } + + [Test] + public void TransformQueryOverToRowCount() + { + QueryOver<Person> expected = + QueryOver.Of<Person>() + .Where(p => p.Name == "test") + .JoinQueryOver(p => p.Children) + .Where((Child c) => c.Age == 5) + .Select(Projections.RowCount()); + + QueryOver<Person> actual = + QueryOver.Of<Person>() + .Where(p => p.Name == "test") + .JoinQueryOver(p => p.Children) + .Where((Child c) => c.Age == 5) + .OrderBy(c => c.Age).Asc + .Skip(20) + .Take(10); + + expected = QueryOverTransformer.Clone(expected); + actual = QueryOverTransformer.TransformToRowCount(actual); + + AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual); + } + } } \ 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: <aye...@us...> - 2010-03-03 17:29:17
|
Revision: 4952 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4952&view=rev Author: ayenderahien Date: 2010-03-03 17:29:11 +0000 (Wed, 03 Mar 2010) Log Message: ----------- Adding passing test Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/App.config trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs Modified: trunk/nhibernate/src/NHibernate.Test/App.config =================================================================== --- trunk/nhibernate/src/NHibernate.Test/App.config 2010-03-03 15:54:34 UTC (rev 4951) +++ trunk/nhibernate/src/NHibernate.Test/App.config 2010-03-03 17:29:11 UTC (rev 4952) @@ -62,7 +62,7 @@ <!-- This is the System.Data.dll provider for MSSQL Server --> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> - <property name="connection.connection_string">Server=localhost;initial catalog=nhibernate;Integrated Security=SSPI</property> + <property name="connection.connection_string">Server=localhost\sqlexpress;initial catalog=nhibernate;Integrated Security=SSPI</property> <property name="show_sql">false</property> <property name="use_outer_join">true</property> Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs 2010-03-03 15:54:34 UTC (rev 4951) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs 2010-03-03 17:29:11 UTC (rev 4952) @@ -31,5 +31,31 @@ .List(); } } + + [Test] + public void QueryPropertyInBothFilterAndQueryUsingWith() + { + using (ISession s = OpenSession()) + { + s.EnableFilter("validity") + .SetParameter("date", DateTime.Now); + + s.CreateQuery(@" + select + inv.ID + from + Invoice inv + join inv.Category cat with cat.ValidUntil > :now + left join cat.ParentCategory parentCat with parentCat.ID != :myInt + where + inv.ID = :invId + and inv.Issued < :now + ") + .SetDateTime("now", DateTime.Now) + .SetInt32("invId", -999) + .SetInt32("myInt", -888) + .List(); + } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs 2010-03-03 15:54:34 UTC (rev 4951) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs 2010-03-03 17:29:11 UTC (rev 4952) @@ -15,4 +15,4 @@ public virtual DateTime Issued { get; set; } public virtual Category Category { get; set; } } -} \ 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: <aye...@us...> - 2010-03-03 15:54:42
|
Revision: 4951 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4951&view=rev Author: ayenderahien Date: 2010-03-03 15:54:34 +0000 (Wed, 03 Mar 2010) Log Message: ----------- Fixing NH-2113 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Type/ComponentType.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113/Model.cs Modified: trunk/nhibernate/src/NHibernate/Type/ComponentType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/ComponentType.cs 2010-03-02 20:55:46 UTC (rev 4950) +++ trunk/nhibernate/src/NHibernate/Type/ComponentType.cs 2010-03-03 15:54:34 UTC (rev 4951) @@ -23,8 +23,9 @@ private readonly FetchMode?[] joinedFetch; private readonly bool isKey; protected internal EntityModeToTuplizerMapping tuplizerMapping; + private bool overridesGetHashCode; - public override SqlType[] SqlTypes(IMapping mapping) + public override SqlType[] SqlTypes(IMapping mapping) { //Not called at runtime so doesn't matter if its slow :) SqlType[] sqlTypes = new SqlType[GetColumnSpan(mapping)]; @@ -72,6 +73,11 @@ } tuplizerMapping = metamodel.TuplizerMapping; + var tuplizer = tuplizerMapping.GetTuplizerOrNull(EntityMode.Poco); + if(tuplizer !=null) + { + overridesGetHashCode = ReflectHelper.OverridesGetHashCode(tuplizer.MappedClass); + } } /// <summary></summary> @@ -100,6 +106,8 @@ public override int GetHashCode(object x, EntityMode entityMode, ISessionFactoryImplementor factory) { + if (overridesGetHashCode) + return x.GetHashCode(); return GetHashCode(x, entityMode); } Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113 ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113/Fixture.cs 2010-03-03 15:54:34 UTC (rev 4951) @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Transactions; +using NHibernate.Dialect; +using NHibernate.Impl; +using NUnit.Framework; +using NHibernate.Criterion; + +namespace NHibernate.Test.NHSpecificTest.NH2113 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + [Test] + public void ShouldNotEagerLoadKeyManyToOneWhenOverridingGetHashCode() + { + using (var s = OpenSession()) + using(var tx = s.BeginTransaction()) + { + var grp = new Group(); + s.Save(grp); + + var broker = new Broker{Key = new Key{BankId = 1, Id = -1}}; + s.Save(broker); + + var load = new Loan {Broker = broker, Group = grp, Name = "money!!!"}; + s.Save(load); + + tx.Commit(); + } + + bool isInitialized; + using (var s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + var loan = s.CreateCriteria<Loan>() + .UniqueResult<Loan>(); + + isInitialized = NHibernateUtil.IsInitialized(loan.Broker); + + tx.Commit(); + } + + + using (var s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + s.Delete("from System.Object"); + + tx.Commit(); + } + + Assert.False(isInitialized); + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113/Mappings.hbm.xml 2010-03-03 15:54:34 UTC (rev 4951) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH2113"> + + <class name="Loan"> + <composite-id> + <key-many-to-one name="Broker" class="Broker"> + <column name="BrokerID"/> + <column name="BankID"/> + </key-many-to-one> + <key-many-to-one name="Group" + column="GroupID" class="Group"/> + </composite-id> + <property name="Name" /> + </class> + + <class name="Group" table="Groups"> + <id name="Id" column="GroupID"> + <generator class="increment"/> + </id> + </class> + + <class name="Broker"> + <composite-id name="Key"> + <key-property name="Id" + column="BrokerID"/> + <key-property name="BankId"/> + </composite-id> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2113/Model.cs 2010-03-03 15:54:34 UTC (rev 4951) @@ -0,0 +1,89 @@ +namespace NHibernate.Test.NHSpecificTest.NH2113 +{ + public class Loan + { + public virtual Broker Broker{ get; set;} + public virtual Group Group { get; set; } + public virtual string Name { get; set; } + + public virtual bool Equals(Loan other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(other.Broker, Broker) && Equals(other.Group, Group); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != typeof (Loan)) return false; + return Equals((Loan) obj); + } + + public override int GetHashCode() + { + unchecked + { + return ((Broker != null ? Broker.Key.GetHashCode() : 0)*397) ^ (Group != null ? Group.GetHashCode() : 0); + } + } + } + + public class Group + { + public virtual int Id { get; set; } + } + public class Broker + { + public virtual Key Key { get; set; } + + public virtual bool Equals(Broker other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(other.Key, Key); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != typeof (Broker)) return false; + return Equals((Broker) obj); + } + + public override int GetHashCode() + { + return (Key != null ? Key.GetHashCode() : 0); + } + } + public class Key + { + public int Id { get; set; } + public int BankId { get; set; } + + public virtual bool Equals(Key other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return other.Id == Id && other.BankId == BankId; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != typeof (Key)) return false; + return Equals((Key) obj); + } + + public override int GetHashCode() + { + unchecked + { + return (Id*397) ^ BankId; + } + } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-03-02 20:55:46 UTC (rev 4950) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-03-03 15:54:34 UTC (rev 4951) @@ -707,6 +707,8 @@ <Compile Include="NHSpecificTest\NH2074\Model.cs" /> <Compile Include="NHSpecificTest\NH2077\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2077\Model.cs" /> + <Compile Include="NHSpecificTest\NH2113\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2113\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -2124,6 +2126,7 @@ <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2113\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1981\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2074\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2077\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2010-03-02 20:56:27
|
Revision: 4950 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4950&view=rev Author: ayenderahien Date: 2010-03-02 20:55:46 +0000 (Tue, 02 Mar 2010) Log Message: ----------- produce pdbs in release builds Modified Paths: -------------- trunk/nhibernate/build-common/common.xml Modified: trunk/nhibernate/build-common/common.xml =================================================================== --- trunk/nhibernate/build-common/common.xml 2010-02-26 21:13:52 UTC (rev 4949) +++ trunk/nhibernate/build-common/common.xml 2010-03-02 20:55:46 UTC (rev 4950) @@ -161,7 +161,7 @@ <target name="set-release-project-configuration" description="Perform a 'release' build"> <property name="build.release" value="true" /> - <property name="build.debug" value="false" /> + <property name="build.debug" value="pdbonly" /> <property name="build.name" value="NHibernate-${project.version}" /> </target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-02-26 21:14:01
|
Revision: 4949 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4949&view=rev Author: steverstrong Date: 2010-02-26 21:13:52 +0000 (Fri, 26 Feb 2010) Log Message: ----------- Added reference to re-linq assembly in Test project Nant script Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.build Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.build =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.build 2010-02-26 20:47:09 UTC (rev 4948) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.build 2010-02-26 21:13:52 UTC (rev 4949) @@ -24,7 +24,8 @@ <include name="LinFu.DynamicProxy.dll" /> <include name="nunit.framework.dll" /> <include name="Antlr3.Runtime.dll" /> - <include name="System.Linq.Dynamic.dll" /> + <include name="Remotion.Data.Linq.dll" /> + <include name="System.Linq.Dynamic.dll" /> </assemblyfileset> <resourcefileset id="project.resources" prefix="NHibernate.Test" dynamicprefix="true"> <include name="**/*.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-02-26 20:47:16
|
Revision: 4948 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4948&view=rev Author: steverstrong Date: 2010-02-26 20:47:09 +0000 (Fri, 26 Feb 2010) Log Message: ----------- Eager loading support in Linq provider Modified Paths: -------------- trunk/nhibernate/lib/net/3.5/Remotion.Data.Linq.dll trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs trunk/nhibernate/src/NHibernate/Linq/NhLinqExpression.cs trunk/nhibernate/src/NHibernate/Linq/NhQueryProvider.cs trunk/nhibernate/src/NHibernate/Linq/ReWriters/AddLeftJoinsReWriter.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionParameterVisitor.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/NhExpressionTreeVisitor.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/NhThrowingExpressionTreeVisitor.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/Nominator.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/IResultOperatorProcessor.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAggregate.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAll.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAny.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessClientSideSelect.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessContains.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessFirst.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessFirstOrSingleBase.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessGroupBy.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessNonAggregatingGroupBy.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessResultOperatorReturn.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessSingle.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessSkip.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessTake.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ResultOperatorMap.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ResultOperatorProcessor.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ResultOperatorProcessorBase.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Customer.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Employee.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Order.cs trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Linq/EagerFetchingExtensionMethods.cs trunk/nhibernate/src/NHibernate/Linq/Expressions/AggregateExpressionNode.cs trunk/nhibernate/src/NHibernate/Linq/IntermediateHqlTree.cs trunk/nhibernate/src/NHibernate/Linq/NhRelinqQueryParser.cs trunk/nhibernate/src/NHibernate/Linq/ResultOperators/AggregateResultOperator.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/NameUnNamedParameters.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/QuerySourceLocator.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessFetch.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessFetchMany.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessFetchOne.cs trunk/nhibernate/src/NHibernate.Test/Linq/EagerLoadTests.cs Property Changed: ---------------- trunk/nhibernate/src/ trunk/nhibernate/src/NHibernate/ Modified: trunk/nhibernate/lib/net/3.5/Remotion.Data.Linq.dll =================================================================== (Binary files differ) Property changes on: trunk/nhibernate/src ___________________________________________________________________ Modified: svn:ignore - *.suo CloverSrc _ReSharper* *.resharperoptions *.resharper.user CloverBuild Ankh.Load *.resharper ConsoleTest _UpgradeReport_Files NHibernate.userprefs NHibernate.usertasks UpgradeLog.XML UpgradeLog2.XML UpgradeLog3.XML UpgradeLog4.XML UpgradeLog5.XML UpgradeLog6.XML UpgradeLog7.XML UpgradeLog8.XML UpgradeLog9.XML NHibernate.sln.proj NHibernate.sln.AssemblySurfaceCache.user NHibernate.sln.cache .git + *.suo CloverSrc _ReSharper* *.resharperoptions *.resharper.user CloverBuild Ankh.Load *.resharper ConsoleTest _UpgradeReport_Files NHibernate.userprefs NHibernate.usertasks UpgradeLog.XML UpgradeLog2.XML UpgradeLog3.XML UpgradeLog4.XML UpgradeLog5.XML UpgradeLog6.XML UpgradeLog7.XML UpgradeLog8.XML UpgradeLog9.XML NHibernate.sln.proj NHibernate.sln.AssemblySurfaceCache.user NHibernate.sln.cache .git .gitignore NHibernate.5.0.ReSharper.user Property changes on: trunk/nhibernate/src/NHibernate ___________________________________________________________________ Modified: svn:ignore - obj .#* *.user *.xsx AssemblyInfo.cs *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* _ReSharper.NHibernate NHibernate.pidb + obj .#* *.user *.xsx AssemblyInfo.cs *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* _ReSharper.NHibernate NHibernate.pidb NHibernate.suo Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -391,9 +391,19 @@ return new HqlIn(_factory, itemExpression, source); } - public HqlTreeNode LeftJoin(HqlExpression expression, HqlAlias @alias) + public HqlLeftJoin LeftJoin(HqlExpression expression, HqlAlias @alias) { return new HqlLeftJoin(_factory, expression, @alias); } + + public HqlFetchJoin FetchJoin(HqlExpression expression, HqlAlias @alias) + { + return new HqlFetchJoin(_factory, expression, @alias); + } + + public HqlLeftFetchJoin LeftFetchJoin(HqlExpression expression, HqlAlias @alias) + { + return new HqlLeftFetchJoin(_factory, expression, @alias); + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -674,6 +674,22 @@ } } + public class HqlFetchJoin : HqlTreeNode + { + public HqlFetchJoin(IASTFactory factory, HqlExpression expression, HqlAlias @alias) + : base(HqlSqlWalker.JOIN, "join", factory, new HqlFetch(factory), expression, @alias) + { + } + } + + public class HqlLeftFetchJoin : HqlTreeNode + { + public HqlLeftFetchJoin(IASTFactory factory, HqlExpression expression, HqlAlias @alias) + : base(HqlSqlWalker.JOIN, "join", factory, new HqlLeft(factory), new HqlFetch(factory), expression, @alias) + { + } + } + public class HqlFetch : HqlTreeNode { public HqlFetch(IASTFactory factory) : base(HqlSqlWalker.FETCH, "fetch", factory) Added: trunk/nhibernate/src/NHibernate/Linq/EagerFetchingExtensionMethods.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/EagerFetchingExtensionMethods.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/EagerFetchingExtensionMethods.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; +using Remotion.Data.Linq.EagerFetching; +using Remotion.Data.Linq.Utilities; + +namespace NHibernate.Linq +{ + public static class EagerFetchingExtensionMethods + { + public static FluentFetchRequest<TOriginating, TRelated> Fetch<TOriginating, TRelated>( + this IQueryable<TOriginating> query, Expression<Func<TOriginating, TRelated>> relatedObjectSelector) + { + ArgumentUtility.CheckNotNull("query", query); + ArgumentUtility.CheckNotNull("relatedObjectSelector", relatedObjectSelector); + + var methodInfo = ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOriginating), typeof(TRelated)); + return CreateFluentFetchRequest<TOriginating, TRelated>(methodInfo, query, relatedObjectSelector); + } + + public static FluentFetchRequest<TOriginating, TRelated> FetchMany<TOriginating, TRelated>( + this IQueryable<TOriginating> query, Expression<Func<TOriginating, IEnumerable<TRelated>>> relatedObjectSelector) + { + ArgumentUtility.CheckNotNull("query", query); + ArgumentUtility.CheckNotNull("relatedObjectSelector", relatedObjectSelector); + + var methodInfo = ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOriginating), typeof(TRelated)); + return CreateFluentFetchRequest<TOriginating, TRelated>(methodInfo, query, relatedObjectSelector); + } + + public static FluentFetchRequest<TQueried, TRelated> ThenFetch<TQueried, TFetch, TRelated>( + this FluentFetchRequest<TQueried, TFetch> query, Expression<Func<TFetch, TRelated>> relatedObjectSelector) + { + ArgumentUtility.CheckNotNull("query", query); + ArgumentUtility.CheckNotNull("relatedObjectSelector", relatedObjectSelector); + + var methodInfo = ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TQueried), typeof(TFetch), typeof(TRelated)); + return CreateFluentFetchRequest<TQueried, TRelated>(methodInfo, query, relatedObjectSelector); + } + + public static FluentFetchRequest<TQueried, TRelated> ThenFetchMany<TQueried, TFetch, TRelated>( + this FluentFetchRequest<TQueried, TFetch> query, Expression<Func<TFetch, IEnumerable<TRelated>>> relatedObjectSelector) + { + ArgumentUtility.CheckNotNull("query", query); + ArgumentUtility.CheckNotNull("relatedObjectSelector", relatedObjectSelector); + + var methodInfo = ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TQueried), typeof(TFetch), typeof(TRelated)); + return CreateFluentFetchRequest<TQueried, TRelated>(methodInfo, query, relatedObjectSelector); + } + + private static FluentFetchRequest<TOriginating, TRelated> CreateFluentFetchRequest<TOriginating, TRelated>( + MethodInfo currentFetchMethod, + IQueryable<TOriginating> query, + LambdaExpression relatedObjectSelector) + { + var queryProvider = query.Provider; // ArgumentUtility.CheckNotNullAndType<QueryProviderBase>("query.Provider", query.Provider); + var callExpression = Expression.Call(currentFetchMethod, query.Expression, relatedObjectSelector); + return new FluentFetchRequest<TOriginating, TRelated>(queryProvider, callExpression); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/Expressions/AggregateExpressionNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Expressions/AggregateExpressionNode.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/Expressions/AggregateExpressionNode.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -0,0 +1,43 @@ +using System; +using System.Linq.Expressions; +using NHibernate.Linq.ResultOperators; +using Remotion.Data.Linq.Clauses; +using Remotion.Data.Linq.Parsing.Structure.IntermediateModel; + +namespace NHibernate.Linq.Expressions +{ + public class AggregateExpressionNode : ResultOperatorExpressionNodeBase + { + public MethodCallExpressionParseInfo ParseInfo { get; set; } + public Expression OptionalSeed { get; set; } + public LambdaExpression Accumulator { get; set; } + public LambdaExpression OptionalSelector { get; set; } + + public AggregateExpressionNode(MethodCallExpressionParseInfo parseInfo, Expression arg1, Expression arg2, LambdaExpression optionalSelector) : base(parseInfo, null, optionalSelector) + { + ParseInfo = parseInfo; + + if (arg2 != null) + { + OptionalSeed = arg1; + Accumulator = (LambdaExpression) arg2; + } + else + { + Accumulator = (LambdaExpression) arg1; + } + + OptionalSelector = optionalSelector; + } + + public override Expression Resolve(ParameterExpression inputParameter, Expression expressionToBeResolved, ClauseGenerationContext clauseGenerationContext) + { + throw new NotImplementedException(); + } + + protected override ResultOperatorBase CreateResultOperator(ClauseGenerationContext clauseGenerationContext) + { + return new AggregateResultOperator(ParseInfo, OptionalSeed, Accumulator, OptionalSelector); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/IntermediateHqlTree.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/IntermediateHqlTree.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/IntermediateHqlTree.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -0,0 +1,145 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using NHibernate.Hql.Ast; +using NHibernate.Transform; +using NHibernate.Type; + +namespace NHibernate.Linq +{ + public class IntermediateHqlTree + { + private readonly bool _root; + private readonly List<Action<IQuery, IDictionary<string, Tuple<object, IType>>>> _additionalCriteria = new List<Action<IQuery, IDictionary<string, Tuple<object, IType>>>>(); + private readonly List<LambdaExpression> _listTransformers = new List<LambdaExpression>(); + private readonly List<LambdaExpression> _itemTransformers = new List<LambdaExpression>(); + private readonly List<LambdaExpression> _postExecuteTransformers = new List<LambdaExpression>(); + private bool _hasDistinctRootOperator; + + public HqlTreeNode Root { get; private set; } + public HqlTreeBuilder TreeBuilder { get; private set; } + + public IntermediateHqlTree(bool root) + { + _root = root; + TreeBuilder = new HqlTreeBuilder(); + Root = TreeBuilder.Query(TreeBuilder.SelectFrom(TreeBuilder.From())); + } + + public ExpressionToHqlTranslationResults GetTranslation() + { + if (_root) + { + DetectOuterExists(); + } + + return new ExpressionToHqlTranslationResults(Root, + _itemTransformers, + _listTransformers, + _postExecuteTransformers, + _additionalCriteria); + } + + public void AddDistinctRootOperator() + { + if (!_hasDistinctRootOperator) + { + Expression<Func<IEnumerable<object>, IList>> x = + l => new DistinctRootEntityResultTransformer().TransformList(l.ToList()); + + _listTransformers.Add(x); + _hasDistinctRootOperator = true; + } + } + + + public void AddItemTransformer(LambdaExpression transformer) + { + _itemTransformers.Add(transformer); + } + + public void AddFromClause(HqlTreeNode from) + { + Root.NodesPreOrder.Where(n => n is HqlFrom).First().AddChild(from); + } + + public void AddSelectClause(HqlTreeNode select) + { + Root.NodesPreOrder.Where(n => n is HqlSelectFrom).First().AddChild(select); + } + + public void AddGroupByClause(HqlGroupBy groupBy) + { + Root.As<HqlQuery>().AddChild(groupBy); + } + + public void AddOrderByClause(HqlExpression orderBy, HqlDirectionStatement direction) + { + var orderByRoot = Root.NodesPreOrder.Where(n => n is HqlOrderBy).FirstOrDefault(); + + if (orderByRoot == null) + { + orderByRoot = TreeBuilder.OrderBy(); + Root.As<HqlQuery>().AddChild(orderByRoot); + } + + orderByRoot.AddChild(orderBy); + orderByRoot.AddChild(direction); + } + + public void AddWhereClause(HqlBooleanExpression where) + { + var currentWhere = Root.NodesPreOrder.Where(n => n is HqlWhere).FirstOrDefault(); + + if (currentWhere == null) + { + currentWhere = TreeBuilder.Where(where); + Root.As<HqlQuery>().AddChild(currentWhere); + } + else + { + var currentClause = (HqlBooleanExpression)currentWhere.Children.Single(); + + currentWhere.ClearChildren(); + currentWhere.AddChild(TreeBuilder.BooleanAnd(currentClause, where)); + } + } + + private void DetectOuterExists() + { + if (Root is HqlExists) + { + Root = Root.Children.First(); + + _additionalCriteria.Add((q, p) => q.SetMaxResults(1)); + + Expression<Func<IEnumerable<object>, bool>> x = l => l.Any(); + + _listTransformers.Add(x); + } + } + + + public void AddAdditionalCriteria(Action<IQuery, IDictionary<string, Tuple<object, IType>>> criteria) + { + _additionalCriteria.Add(criteria); + } + + public void AddPostExecuteTransformer(LambdaExpression lambda) + { + _postExecuteTransformers.Add(lambda); + } + + public void AddListTransformer(LambdaExpression lambda) + { + _listTransformers.Add(lambda); + } + + public void SetRoot(HqlTreeNode newRoot) + { + Root = newRoot; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -19,6 +19,11 @@ } } + public static bool IsEnumerableOfT(this System.Type type) + { + return type.IsGenericType && type.GetGenericTypeDefinition() == typeof (IEnumerable<>); + } + public static bool IsNullable(this System.Type type) { return (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)); Modified: trunk/nhibernate/src/NHibernate/Linq/NhLinqExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/NhLinqExpression.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/NhLinqExpression.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -1,17 +1,11 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using NHibernate.Engine.Query; using NHibernate.Hql.Ast.ANTLR.Tree; -using NHibernate.Linq.ResultOperators; using NHibernate.Linq.Visitors; using NHibernate.Type; -using Remotion.Data.Linq; -using Remotion.Data.Linq.Clauses; using Remotion.Data.Linq.Parsing.ExpressionTreeVisitors; -using Remotion.Data.Linq.Parsing.Structure; -using Remotion.Data.Linq.Parsing.Structure.IntermediateModel; namespace NHibernate.Linq { @@ -83,118 +77,4 @@ return _astNode; } } - - public static class NhRelinqQueryParser - { - public static readonly MethodCallExpressionNodeTypeRegistry MethodCallRegistry = - MethodCallExpressionNodeTypeRegistry.CreateDefault(); - - static NhRelinqQueryParser() - { - MethodCallRegistry.Register( - new[] - { - MethodCallExpressionNodeTypeRegistry.GetRegisterableMethodDefinition(ReflectionHelper.GetMethod(() => Queryable.Aggregate<object>(null, null))), - MethodCallExpressionNodeTypeRegistry.GetRegisterableMethodDefinition(ReflectionHelper.GetMethod(() => Queryable.Aggregate<object, object>(null, null, null))) - }, - typeof (AggregateExpressionNode)); - - MethodCallRegistry.Register( - new [] - { - MethodCallExpressionNodeTypeRegistry.GetRegisterableMethodDefinition(ReflectionHelper.GetMethod((List<object> l) => l.Contains(null))), - - }, - typeof(ContainsExpressionNode)); - } - - public static QueryModel Parse(Expression expression) - { - return new QueryParser(new ExpressionTreeParser(MethodCallRegistry)).GetParsedQuery(expression); - } - } - - public class NameUnNamedParameters : NhExpressionTreeVisitor - { - public static Expression Visit(Expression expression) - { - var visitor = new NameUnNamedParameters(); - - return visitor.VisitExpression(expression); - } - - private readonly Dictionary<ParameterExpression, ParameterExpression> _renamedParameters = new Dictionary<ParameterExpression, ParameterExpression>(); - - protected override Expression VisitParameterExpression(ParameterExpression expression) - { - if (string.IsNullOrEmpty(expression.Name)) - { - ParameterExpression renamed; - - if (_renamedParameters.TryGetValue(expression, out renamed)) - { - return renamed; - } - - renamed = Expression.Parameter(expression.Type, Guid.NewGuid().ToString()); - - _renamedParameters.Add(expression, renamed); - - return renamed; - } - - return base.VisitParameterExpression(expression); - } - } - - public class AggregateExpressionNode : ResultOperatorExpressionNodeBase - { - public MethodCallExpressionParseInfo ParseInfo { get; set; } - public Expression OptionalSeed { get; set; } - public LambdaExpression Accumulator { get; set; } - public LambdaExpression OptionalSelector { get; set; } - - public AggregateExpressionNode(MethodCallExpressionParseInfo parseInfo, Expression arg1, Expression arg2, LambdaExpression optionalSelector) : base(parseInfo, null, optionalSelector) - { - ParseInfo = parseInfo; - - if (arg2 != null) - { - OptionalSeed = arg1; - Accumulator = (LambdaExpression) arg2; - } - else - { - Accumulator = (LambdaExpression) arg1; - } - - OptionalSelector = optionalSelector; - } - - public override Expression Resolve(ParameterExpression inputParameter, Expression expressionToBeResolved, ClauseGenerationContext clauseGenerationContext) - { - throw new NotImplementedException(); - } - - protected override ResultOperatorBase CreateResultOperator(ClauseGenerationContext clauseGenerationContext) - { - return new AggregateResultOperator(ParseInfo, OptionalSeed, Accumulator, OptionalSelector); - } - } - - public class AggregateResultOperator : ClientSideTransformOperator - { - public MethodCallExpressionParseInfo ParseInfo { get; set; } - public Expression OptionalSeed { get; set; } - public LambdaExpression Accumulator { get; set; } - public LambdaExpression OptionalSelector { get; set; } - - public AggregateResultOperator(MethodCallExpressionParseInfo parseInfo, Expression optionalSeed, LambdaExpression accumulator, LambdaExpression optionalSelector) - { - ParseInfo = parseInfo; - OptionalSeed = optionalSeed; - Accumulator = accumulator; - OptionalSelector = optionalSelector; - } - } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/NhQueryProvider.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/NhQueryProvider.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/NhQueryProvider.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -1,5 +1,4 @@ -using System; -using System.Collections; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; Added: trunk/nhibernate/src/NHibernate/Linq/NhRelinqQueryParser.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/NhRelinqQueryParser.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/NhRelinqQueryParser.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using Remotion.Data.Linq; +using Remotion.Data.Linq.EagerFetching.Parsing; +using Remotion.Data.Linq.Parsing.Structure; +using Remotion.Data.Linq.Parsing.Structure.IntermediateModel; +using AggregateExpressionNode = NHibernate.Linq.Expressions.AggregateExpressionNode; + +namespace NHibernate.Linq +{ + public static class NhRelinqQueryParser + { + public static readonly MethodCallExpressionNodeTypeRegistry MethodCallRegistry = + MethodCallExpressionNodeTypeRegistry.CreateDefault(); + + static NhRelinqQueryParser() + { + MethodCallRegistry.Register( + new[] + { + MethodCallExpressionNodeTypeRegistry.GetRegisterableMethodDefinition( + ReflectionHelper.GetMethod(() => Queryable.Aggregate<object>(null, null))), + MethodCallExpressionNodeTypeRegistry.GetRegisterableMethodDefinition( + ReflectionHelper.GetMethod(() => Queryable.Aggregate<object, object>(null, null, null))) + }, + typeof (AggregateExpressionNode)); + + MethodCallRegistry.Register( + new[] + { + MethodCallExpressionNodeTypeRegistry.GetRegisterableMethodDefinition( + ReflectionHelper.GetMethod((List<object> l) => l.Contains(null))), + + }, + typeof (ContainsExpressionNode)); + + MethodCallRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("Fetch") }, typeof(FetchOneExpressionNode)); + MethodCallRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("FetchMany") }, typeof(FetchManyExpressionNode)); + MethodCallRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("ThenFetch") }, typeof(ThenFetchOneExpressionNode)); + MethodCallRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("ThenFetchMany") }, typeof(ThenFetchManyExpressionNode)); + + } + + public static QueryModel Parse(Expression expression) + { + return new QueryParser(new ExpressionTreeParser(MethodCallRegistry)).GetParsedQuery(expression); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/ReWriters/AddLeftJoinsReWriter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/ReWriters/AddLeftJoinsReWriter.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/ReWriters/AddLeftJoinsReWriter.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -56,7 +56,7 @@ return swapper.VisitExpression(expression); } - protected override Expression VisitExpression(Expression expression) + public override Expression VisitExpression(Expression expression) { if (expression == null) { Added: trunk/nhibernate/src/NHibernate/Linq/ResultOperators/AggregateResultOperator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/ResultOperators/AggregateResultOperator.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/ResultOperators/AggregateResultOperator.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -0,0 +1,21 @@ +using System.Linq.Expressions; +using Remotion.Data.Linq.Parsing.Structure.IntermediateModel; + +namespace NHibernate.Linq.ResultOperators +{ + public class AggregateResultOperator : ClientSideTransformOperator + { + public MethodCallExpressionParseInfo ParseInfo { get; set; } + public Expression OptionalSeed { get; set; } + public LambdaExpression Accumulator { get; set; } + public LambdaExpression OptionalSelector { get; set; } + + public AggregateResultOperator(MethodCallExpressionParseInfo parseInfo, Expression optionalSeed, LambdaExpression accumulator, LambdaExpression optionalSelector) + { + ParseInfo = parseInfo; + OptionalSeed = optionalSeed; + Accumulator = accumulator; + OptionalSelector = optionalSelector; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -2,7 +2,6 @@ using System.Collections.ObjectModel; using System.Linq.Expressions; using System.Text; -using Remotion.Data.Linq.Parsing; namespace NHibernate.Linq.Visitors { @@ -13,7 +12,7 @@ /// generate the same key as /// from c in Customers where c.City = "Madrid" /// </summary> - public class ExpressionKeyVisitor : ExpressionTreeVisitor + public class ExpressionKeyVisitor : NhExpressionTreeVisitor { private readonly IDictionary<ConstantExpression, NamedParameter> _constantToParameterMap; readonly StringBuilder _string = new StringBuilder(); @@ -93,22 +92,14 @@ return base.VisitElementInit(elementInit); } - protected override ReadOnlyCollection<T> VisitExpressionList<T>(ReadOnlyCollection<T> expressions) - { - if (expressions.Count > 0) - { - VisitExpression(expressions[0]); + private T AppendCommas<T>(T expression) where T : Expression + { + VisitExpression(expression); + _string.Append(", "); - for (var i = 1; i < expressions.Count; i++) - { - _string.Append(", "); - VisitExpression(expressions[i]); - } - } + return expression; + } - return expressions; - } - protected override Expression VisitInvocationExpression(InvocationExpression expression) { return base.VisitInvocationExpression(expression); @@ -117,7 +108,8 @@ protected override Expression VisitLambdaExpression(LambdaExpression expression) { _string.Append('('); - VisitExpressionList(expression.Parameters); + + VisitList(expression.Parameters, AppendCommas); _string.Append(") => ("); VisitExpression(expression.Body); _string.Append(')'); @@ -171,7 +163,7 @@ _string.Append('.'); _string.Append(expression.Method.Name); _string.Append('('); - VisitExpressionList(expression.Arguments); + VisitList(expression.Arguments, AppendCommas); _string.Append(')'); return expression; @@ -187,7 +179,7 @@ _string.Append("new "); _string.Append(expression.Constructor.DeclaringType.Name); _string.Append('('); - VisitExpressionList(expression.Arguments); + VisitList(expression.Arguments, AppendCommas); _string.Append(')'); return expression; Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionParameterVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionParameterVisitor.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionParameterVisitor.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -2,14 +2,13 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; -using Remotion.Data.Linq.Parsing; namespace NHibernate.Linq.Visitors { /// <summary> /// Locates constants in the expression tree and generates parameters for each one /// </summary> - public class ExpressionParameterVisitor : ExpressionTreeVisitor + public class ExpressionParameterVisitor : NhExpressionTreeVisitor { private readonly Dictionary<ConstantExpression, NamedParameter> _parameters = new Dictionary<ConstantExpression, NamedParameter>(); Added: trunk/nhibernate/src/NHibernate/Linq/Visitors/NameUnNamedParameters.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/NameUnNamedParameters.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/NameUnNamedParameters.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq.Expressions; + +namespace NHibernate.Linq.Visitors +{ + public class NameUnNamedParameters : NhExpressionTreeVisitor + { + public static Expression Visit(Expression expression) + { + var visitor = new NameUnNamedParameters(); + + return visitor.VisitExpression(expression); + } + + private readonly Dictionary<ParameterExpression, ParameterExpression> _renamedParameters = new Dictionary<ParameterExpression, ParameterExpression>(); + + protected override Expression VisitParameterExpression(ParameterExpression expression) + { + if (string.IsNullOrEmpty(expression.Name)) + { + ParameterExpression renamed; + + if (_renamedParameters.TryGetValue(expression, out renamed)) + { + return renamed; + } + + renamed = Expression.Parameter(expression.Type, Guid.NewGuid().ToString()); + + _renamedParameters.Add(expression, renamed); + + return renamed; + } + + return base.VisitParameterExpression(expression); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/NhExpressionTreeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/NhExpressionTreeVisitor.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/NhExpressionTreeVisitor.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -7,7 +7,7 @@ { public class NhExpressionTreeVisitor : ExpressionTreeVisitor { - protected override Expression VisitExpression(Expression expression) + public override Expression VisitExpression(Expression expression) { if (expression == null) { @@ -27,7 +27,6 @@ return VisitNhNew((NhNewExpression) expression); case NhExpressionType.Star: return VisitNhStar((NhStarExpression) expression); - } return base.VisitExpression(expression); @@ -42,7 +41,7 @@ protected virtual Expression VisitNhNew(NhNewExpression expression) { - var arguments = VisitExpressionList(expression.Arguments); + var arguments = VisitAndConvert(expression.Arguments, "VisitNhNew"); return arguments != expression.Arguments ? new NhNewExpression(expression.Members, arguments) : expression; } Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/NhThrowingExpressionTreeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/NhThrowingExpressionTreeVisitor.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/NhThrowingExpressionTreeVisitor.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -7,7 +7,7 @@ { public abstract class NhThrowingExpressionTreeVisitor : ThrowingExpressionTreeVisitor { - protected override Expression VisitExpression(Expression expression) + public override Expression VisitExpression(Expression expression) { switch ((NhExpressionType)expression.NodeType) { @@ -125,7 +125,7 @@ protected Expression BaseVisitNhNew(NhNewExpression expression) { - var arguments = base.VisitExpressionList(expression.Arguments); + var arguments = base.VisitAndConvert(expression.Arguments, "BaseVisitNhNew"); return arguments != expression.Arguments ? new NhNewExpression(expression.Members, arguments) : expression; } Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/Nominator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/Nominator.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/Nominator.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -28,7 +28,7 @@ return _candidates; } - protected override Expression VisitExpression(Expression expression) + public override Expression VisitExpression(Expression expression) { if (expression != null) { Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using NHibernate.Hql.Ast; @@ -8,12 +7,13 @@ using NHibernate.Linq.ResultOperators; using NHibernate.Linq.ReWriters; using NHibernate.Linq.Visitors.ResultOperatorProcessors; -using NHibernate.Type; using Remotion.Data.Linq; using Remotion.Data.Linq.Clauses; using Remotion.Data.Linq.Clauses.Expressions; using Remotion.Data.Linq.Clauses.ResultOperators; using Remotion.Data.Linq.Clauses.StreamedData; +using Remotion.Data.Linq.EagerFetching; +using AggregateResultOperator = NHibernate.Linq.ResultOperators.AggregateResultOperator; namespace NHibernate.Linq.Visitors { @@ -48,23 +48,16 @@ var visitor = new QueryModelVisitor(parameters, root, queryModel); visitor.Visit(); - return visitor.GetTranslation(); + return visitor._hqlTree.GetTranslation(); } + private readonly IntermediateHqlTree _hqlTree; private static readonly ResultOperatorMap ResultOperatorMap; - - private readonly List<Action<IQuery, IDictionary<string, Tuple<object, IType>>>> _additionalCriteria = new List<Action<IQuery, IDictionary<string, Tuple<object, IType>>>>(); - private readonly List<LambdaExpression> _listTransformers = new List<LambdaExpression>(); - private readonly List<LambdaExpression> _itemTransformers = new List<LambdaExpression>(); - private readonly List<LambdaExpression> _postExecuteTransformers = new List<LambdaExpression>(); - private readonly bool _root; private bool _serverSide = true; - public HqlTreeNode Root { get; private set; } public VisitorParameters VisitorParameters { get; private set; } public IStreamedDataInfo CurrentEvaluationType { get; private set; } public IStreamedDataInfo PreviousEvaluationType { get; private set; } - public HqlTreeBuilder TreeBuilder { get; private set; } public QueryModel Model { get; private set; } static QueryModelVisitor() @@ -82,15 +75,16 @@ ResultOperatorMap.Add<ClientSideSelect, ProcessClientSideSelect>(); ResultOperatorMap.Add<AnyResultOperator, ProcessAny>(); ResultOperatorMap.Add<AllResultOperator, ProcessAll>(); + ResultOperatorMap.Add<FetchOneRequest, ProcessFetchOne>(); + ResultOperatorMap.Add<FetchManyRequest, ProcessFetchMany>(); } private QueryModelVisitor(VisitorParameters visitorParameters, bool root, QueryModel queryModel) { VisitorParameters = visitorParameters; Model = queryModel; - _root = root; - TreeBuilder = new HqlTreeBuilder(); - Root = TreeBuilder.Query(TreeBuilder.SelectFrom(TreeBuilder.From())); + + _hqlTree = new IntermediateHqlTree(root); } private void Visit() @@ -98,92 +92,15 @@ VisitQueryModel(Model); } - - private ExpressionToHqlTranslationResults GetTranslation() - { - if (_root) - { - DetectOuterExists(); - } - - return new ExpressionToHqlTranslationResults(Root, - _itemTransformers, - _listTransformers, - _postExecuteTransformers, - _additionalCriteria); - } - - private void DetectOuterExists() - { - if (Root is HqlExists) - { - Root = Root.Children.First(); - - _additionalCriteria.Add((q, p) => q.SetMaxResults(1)); - - Expression<Func<IEnumerable<object>, bool>> x = l => l.Any(); - - _listTransformers.Add(x); - } - } - public override void VisitMainFromClause(MainFromClause fromClause, QueryModel queryModel) { - AddFromClause(TreeBuilder.Range( - HqlGeneratorExpressionTreeVisitor.Visit(fromClause.FromExpression, VisitorParameters), - TreeBuilder.Alias(fromClause.ItemName))); + _hqlTree.AddFromClause(_hqlTree.TreeBuilder.Range( + HqlGeneratorExpressionTreeVisitor.Visit(fromClause.FromExpression, VisitorParameters), + _hqlTree.TreeBuilder.Alias(fromClause.ItemName))); base.VisitMainFromClause(fromClause, queryModel); } - - private void AddWhereClause(HqlBooleanExpression where) - { - var currentWhere = Root.NodesPreOrder.Where(n => n is HqlWhere).FirstOrDefault(); - - if (currentWhere == null) - { - currentWhere = TreeBuilder.Where(where); - Root.As<HqlQuery>().AddChild(currentWhere); - } - else - { - var currentClause = (HqlBooleanExpression)currentWhere.Children.Single(); - - currentWhere.ClearChildren(); - currentWhere.AddChild(TreeBuilder.BooleanAnd(currentClause, where)); - } - } - - private void AddFromClause(HqlTreeNode from) - { - Root.NodesPreOrder.Where(n => n is HqlFrom).First().AddChild(from); - } - - private void AddSelectClause(HqlTreeNode select) - { - Root.NodesPreOrder.Where(n => n is HqlSelectFrom).First().AddChild(select); - } - - private void AddGroupByClause(HqlGroupBy groupBy) - { - Root.As<HqlQuery>().AddChild(groupBy); - } - - private void AddOrderByClause(HqlExpression orderBy, HqlDirectionStatement direction) - { - var orderByRoot = Root.NodesPreOrder.Where(n => n is HqlOrderBy).FirstOrDefault(); - - if (orderByRoot == null) - { - orderByRoot = TreeBuilder.OrderBy(); - Root.As<HqlQuery>().AddChild(orderByRoot); - } - - orderByRoot.AddChild(orderBy); - orderByRoot.AddChild(direction); - } - public override void VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, int index) { PreviousEvaluationType = CurrentEvaluationType; @@ -201,32 +118,7 @@ } } - var results = ResultOperatorMap.Process(resultOperator, this); - - if (results.AdditionalCriteria != null) - { - _additionalCriteria.Add(results.AdditionalCriteria); - } - if (results.GroupBy != null) - { - AddGroupByClause(results.GroupBy); - } - if (results.ListTransformer != null) - { - _listTransformers.Add(results.ListTransformer); - } - if (results.PostExecuteTransformer != null) - { - _postExecuteTransformers.Add(results.PostExecuteTransformer); - } - if (results.WhereClause != null) - { - AddWhereClause(results.WhereClause); - } - if (results.TreeNode != null) - { - Root = results.TreeNode; - } + ResultOperatorMap.Process(resultOperator, this, _hqlTree); } private void GroupBy<TSource, TKey, TResult>(Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TResult>> elementSelector) @@ -246,10 +138,10 @@ if (visitor.ProjectionExpression != null) { - _itemTransformers.Add(visitor.ProjectionExpression); + _hqlTree.AddItemTransformer(visitor.ProjectionExpression); } - AddSelectClause(TreeBuilder.Select(visitor.GetHqlNodes())); + _hqlTree.AddSelectClause(_hqlTree.TreeBuilder.Select(visitor.GetHqlNodes())); base.VisitSelectClause(selectClause, queryModel); } @@ -257,17 +149,17 @@ public override void VisitWhereClause(WhereClause whereClause, QueryModel queryModel, int index) { // Visit the predicate to build the query - AddWhereClause(HqlGeneratorExpressionTreeVisitor.Visit(whereClause.Predicate, VisitorParameters).AsBooleanExpression()); + _hqlTree.AddWhereClause(HqlGeneratorExpressionTreeVisitor.Visit(whereClause.Predicate, VisitorParameters).AsBooleanExpression()); } public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index) { foreach (Ordering clause in orderByClause.Orderings) { - AddOrderByClause(HqlGeneratorExpressionTreeVisitor.Visit(clause.Expression, VisitorParameters).AsExpression(), + _hqlTree.AddOrderByClause(HqlGeneratorExpressionTreeVisitor.Visit(clause.Expression, VisitorParameters).AsExpression(), clause.OrderingDirection == OrderingDirection.Asc - ? TreeBuilder.Ascending() - : (HqlDirectionStatement) TreeBuilder.Descending()); + ? _hqlTree.TreeBuilder.Ascending() + : (HqlDirectionStatement) _hqlTree.TreeBuilder.Descending()); } } @@ -276,10 +168,10 @@ var equalityVisitor = new EqualityHqlGenerator(VisitorParameters); var whereClause = equalityVisitor.Visit(joinClause.InnerKeySelector, joinClause.OuterKeySelector); - AddWhereClause(whereClause); + _hqlTree.AddWhereClause(whereClause); - AddFromClause(TreeBuilder.Range(HqlGeneratorExpressionTreeVisitor.Visit(joinClause.InnerSequence, VisitorParameters), - TreeBuilder.Alias(joinClause.ItemName))); + _hqlTree.AddFromClause(_hqlTree.TreeBuilder.Range(HqlGeneratorExpressionTreeVisitor.Visit(joinClause.InnerSequence, VisitorParameters), + _hqlTree.TreeBuilder.Alias(joinClause.ItemName))); } public override void VisitAdditionalFromClause(AdditionalFromClause fromClause, QueryModel queryModel, int index) @@ -287,9 +179,9 @@ if (fromClause is LeftJoinClause) { // It's a left join - AddFromClause(TreeBuilder.LeftJoin( + _hqlTree.AddFromClause(_hqlTree.TreeBuilder.LeftJoin( HqlGeneratorExpressionTreeVisitor.Visit(fromClause.FromExpression, VisitorParameters).AsExpression(), - TreeBuilder.Alias(fromClause.ItemName))); + _hqlTree.TreeBuilder.Alias(fromClause.ItemName))); } else if (fromClause.FromExpression is MemberExpression) { @@ -298,9 +190,9 @@ if (member.Expression is QuerySourceReferenceExpression) { // It's a join - AddFromClause(TreeBuilder.Join( + _hqlTree.AddFromClause(_hqlTree.TreeBuilder.Join( HqlGeneratorExpressionTreeVisitor.Visit(fromClause.FromExpression, VisitorParameters).AsExpression(), - TreeBuilder.Alias(fromClause.ItemName))); + _hqlTree.TreeBuilder.Alias(fromClause.ItemName))); } else { @@ -311,9 +203,9 @@ else { // TODO - exact same code as in MainFromClause; refactor this out - AddFromClause(TreeBuilder.Range( + _hqlTree.AddFromClause(_hqlTree.TreeBuilder.Range( HqlGeneratorExpressionTreeVisitor.Visit(fromClause.FromExpression, VisitorParameters), - TreeBuilder.Alias(fromClause.ItemName))); + _hqlTree.TreeBuilder.Alias(fromClause.ItemName))); } Added: trunk/nhibernate/src/NHibernate/Linq/Visitors/QuerySourceLocator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/QuerySourceLocator.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/QuerySourceLocator.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -0,0 +1,37 @@ +using Remotion.Data.Linq; +using Remotion.Data.Linq.Clauses; + +namespace NHibernate.Linq.Visitors +{ + public class QuerySourceLocator : QueryModelVisitorBase + { + private readonly System.Type _type; + private IQuerySource _querySource; + + private QuerySourceLocator(System.Type type) + { + _type = type; + } + + public static IQuerySource FindQuerySource(QueryModel queryModel, System.Type type) + { + var finder = new QuerySourceLocator(type); + + finder.VisitQueryModel(queryModel); + + return finder._querySource; + } + + public override void VisitMainFromClause(MainFromClause fromClause, QueryModel queryModel) + { + if (_type == fromClause.ItemType) + { + _querySource = fromClause; + } + else + { + base.VisitMainFromClause(fromClause, queryModel); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/IResultOperatorProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/IResultOperatorProcessor.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/IResultOperatorProcessor.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -2,6 +2,6 @@ { public interface IResultOperatorProcessor<T> { - ProcessResultOperatorReturn Process(T resultOperator, QueryModelVisitor queryModelVisitor); + void Process(T resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree); } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAggregate.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAggregate.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAggregate.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -2,12 +2,13 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using NHibernate.Linq.ResultOperators; namespace NHibernate.Linq.Visitors.ResultOperatorProcessors { public class ProcessAggregate : IResultOperatorProcessor<AggregateResultOperator> { - public ProcessResultOperatorReturn Process(AggregateResultOperator resultOperator, QueryModelVisitor queryModelVisitor) + public void Process(AggregateResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree) { var inputType = resultOperator.Accumulator.Parameters[1].Type; var accumulatorType = resultOperator.Accumulator.Parameters[0].Type; @@ -57,7 +58,7 @@ ); } - return new ProcessResultOperatorReturn { ListTransformer = Expression.Lambda(call, inputList) }; + tree.AddListTransformer(Expression.Lambda(call, inputList)); } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAll.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAll.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAll.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -5,15 +5,13 @@ { public class ProcessAll : IResultOperatorProcessor<AllResultOperator> { - public ProcessResultOperatorReturn Process(AllResultOperator resultOperator, QueryModelVisitor queryModelVisitor) + public void Process(AllResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree) { - return new ProcessResultOperatorReturn - { - WhereClause = queryModelVisitor.TreeBuilder.BooleanNot( + tree.AddWhereClause(tree.TreeBuilder.BooleanNot( HqlGeneratorExpressionTreeVisitor.Visit(resultOperator.Predicate, queryModelVisitor.VisitorParameters). - AsBooleanExpression()), - TreeNode = queryModelVisitor.TreeBuilder.BooleanNot(queryModelVisitor.TreeBuilder.Exists((HqlQuery)queryModelVisitor.Root)) - }; + AsBooleanExpression())); + + tree.SetRoot(tree.TreeBuilder.BooleanNot(tree.TreeBuilder.Exists((HqlQuery) tree.Root))); } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAny.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAny.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAny.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -5,12 +5,9 @@ { public class ProcessAny : IResultOperatorProcessor<AnyResultOperator> { - public ProcessResultOperatorReturn Process(AnyResultOperator anyOperator, QueryModelVisitor queryModelVisitor) + public void Process(AnyResultOperator anyOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree) { - return new ProcessResultOperatorReturn - { - TreeNode = queryModelVisitor.TreeBuilder.Exists((HqlQuery) queryModelVisitor.Root) - }; + tree.SetRoot(tree.TreeBuilder.Exists((HqlQuery) tree.Root)); } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessClientSideSelect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessClientSideSelect.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessClientSideSelect.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -7,7 +7,7 @@ { public class ProcessClientSideSelect : IResultOperatorProcessor<ClientSideSelect> { - public ProcessResultOperatorReturn Process(ClientSideSelect resultOperator, QueryModelVisitor queryModelVisitor) + public void Process(ClientSideSelect resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree) { var inputType = resultOperator.SelectClause.Parameters[0].Type; var outputType = resultOperator.SelectClause.Type.GetGenericArguments()[1]; @@ -22,7 +22,7 @@ Expression.Call(selectMethod, inputList, resultOperator.SelectClause)), inputList); - return new ProcessResultOperatorReturn {ListTransformer = lambda}; + tree.AddListTransformer(lambda); } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessContains.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessContains.cs 2010-02-24 21:23:13 UTC (rev 4947) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessContains.cs 2010-02-26 20:47:09 UTC (rev 4948) @@ -6,30 +6,27 @@ { public class ProcessContains : IResultOperatorProcessor<ContainsResultOperator> { - public ProcessResultOperatorReturn Process(ContainsResultOperator resultOperator, QueryModelVisitor queryModelVisitor) + public void Process(ContainsResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree) { var itemExpression = HqlGeneratorExpressionTreeVisitor.Visit(resultOperator.Item, queryModelVisitor.VisitorParameters) .AsExpression(); - var from = GetFromRangeClause(queryModelVisitor.Root); + var from = GetFromRangeClause(tree.Root); var source = from.Children.First(); if (source is HqlParameter) { // This is an "in" style statement - return new ProcessResultOperatorReturn {TreeNode = queryModelVisitor.TreeBuilder.In(itemExpression, source)}; + tree.SetRoot(tree.TreeBuilder.In(itemExpression, source)); } else { // This is an "exists" style statement - return new ProcessResultOperatorReturn - { - ... [truncated message content] |
From: <ric...@us...> - 2010-02-24 21:23:19
|
Revision: 4947 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4947&view=rev Author: ricbrown Date: 2010-02-24 21:23:13 +0000 (Wed, 24 Feb 2010) Log Message: ----------- Enabled test for NH-1981 (Fixed for NH-2009) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH892/Fixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH892/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH892/Fixture.cs 2010-02-24 16:45:34 UTC (rev 4946) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH892/Fixture.cs 2010-02-24 21:23:13 UTC (rev 4947) @@ -14,7 +14,7 @@ get { return "NH892"; } } - [Test, Ignore("Not Fixed yet")] + [Test] public void SelectWithWhereClause() { using (session = OpenSession()) @@ -44,9 +44,8 @@ Assert.AreEqual(post.ID, retrievedPost.ID); Assert.AreEqual(user1.ID, retrievedPost.Poster.ID); - session.Delete(post); - session.Delete(user1); - session.Delete(user2); + session.Delete("from BlogPost"); + session.Delete("from User"); session.Flush(); session.Close(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-02-24 16:46:00
|
Revision: 4946 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4946&view=rev Author: steverstrong Date: 2010-02-24 16:45:34 +0000 (Wed, 24 Feb 2010) Log Message: ----------- Fixed a test that got "refactored" by mistake... Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs 2010-02-24 15:52:13 UTC (rev 4945) +++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs 2010-02-24 16:45:34 UTC (rev 4946) @@ -55,7 +55,7 @@ using(var s = sessions.OpenSession()) using (var tx = s.BeginTransaction()) { - s.Delete("from Root"); + s.Delete("from TreeNode"); tx.Commit(); } @@ -69,9 +69,9 @@ string expectedMessage = string.Format( @"could not execute query -[ SELECT this_.Id as y0_, count(this_.Area) as y1_ FROM Root this_ WHERE this_.Id = {0} ] +[ SELECT this_.Id as y0_, count(this_.Area) as y1_ FROM TreeNode this_ WHERE this_.Id = {0} ] Positional parameters: #0>2 -[SQL: SELECT this_.Id as y0_, count(this_.Area) as y1_ FROM Root this_ WHERE this_.Id = {1}]", +[SQL: SELECT this_.Id as y0_, count(this_.Area) as y1_ FROM TreeNode this_ WHERE this_.Id = {1}]", pName, pName); DetachedCriteria projection = DetachedCriteria.For<TreeNode>("child") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2010-02-24 15:52:33
|
Revision: 4945 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4945&view=rev Author: steverstrong Date: 2010-02-24 15:52:13 +0000 (Wed, 24 Feb 2010) Log Message: ----------- Linq provider now adds correct left join when accessing entity references in projections. Also some refactoring to the ResultOperator processing Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs trunk/nhibernate/src/NHibernate/Linq/GroupBy/NonAggregatingGroupByRewriter.cs trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs trunk/nhibernate/src/NHibernate/Linq/NhLinqExpression.cs trunk/nhibernate/src/NHibernate/Linq/ReWriters/MergeAggregatingResultsRewriter.cs trunk/nhibernate/src/NHibernate/Linq/ResultTransformer.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/EqualityHqlGenerator.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Linq/FunctionTests.cs trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs trunk/nhibernate/src/NHibernate.Test/Linq/MethodCallTests.cs trunk/nhibernate/src/NHibernate.Test/Linq/MiscellaneousTextFixture.cs trunk/nhibernate/src/NHibernate.Test/Linq/QueryReuseTests.cs trunk/nhibernate/src/NHibernate.Test/Linq/RegresstionTests.cs trunk/nhibernate/src/NHibernate.Test/Linq/SelectionTests.cs trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Linq/Clauses/ trunk/nhibernate/src/NHibernate/Linq/Clauses/LeftJoinClause.cs trunk/nhibernate/src/NHibernate/Linq/ReWriters/AddLeftJoinsReWriter.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/LeftJoinDetector.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/NameGenerator.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/IResultOperatorProcessor.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAggregate.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAll.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAny.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessClientSideSelect.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessContains.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessFirst.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessFirstOrSingleBase.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessGroupBy.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessNonAggregatingGroupBy.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessResultOperatorReturn.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessSingle.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessSkip.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessTake.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ResultOperatorMap.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ResultOperatorProcessor.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ResultOperatorProcessorBase.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/VisitorParameters.cs Property Changed: ---------------- trunk/nhibernate/src/ Property changes on: trunk/nhibernate/src ___________________________________________________________________ Modified: svn:ignore - *.suo CloverSrc _ReSharper* *.resharperoptions *.resharper.user CloverBuild Ankh.Load *.resharper ConsoleTest _UpgradeReport_Files NHibernate.userprefs NHibernate.usertasks UpgradeLog.XML UpgradeLog2.XML UpgradeLog3.XML UpgradeLog4.XML UpgradeLog5.XML UpgradeLog6.XML UpgradeLog7.XML UpgradeLog8.XML UpgradeLog9.XML NHibernate.sln.proj NHibernate.sln.AssemblySurfaceCache.user NHibernate.sln.cache + *.suo CloverSrc _ReSharper* *.resharperoptions *.resharper.user CloverBuild Ankh.Load *.resharper ConsoleTest _UpgradeReport_Files NHibernate.userprefs NHibernate.usertasks UpgradeLog.XML UpgradeLog2.XML UpgradeLog3.XML UpgradeLog4.XML UpgradeLog5.XML UpgradeLog6.XML UpgradeLog7.XML UpgradeLog8.XML UpgradeLog9.XML NHibernate.sln.proj NHibernate.sln.AssemblySurfaceCache.user NHibernate.sln.cache .git Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs 2010-02-16 22:50:19 UTC (rev 4944) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -390,5 +390,10 @@ { return new HqlIn(_factory, itemExpression, source); } + + public HqlTreeNode LeftJoin(HqlExpression expression, HqlAlias @alias) + { + return new HqlLeftJoin(_factory, expression, @alias); + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs 2010-02-16 22:50:19 UTC (rev 4944) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -667,6 +667,28 @@ } } + public class HqlLeftJoin : HqlTreeNode + { + public HqlLeftJoin(IASTFactory factory, HqlExpression expression, HqlAlias @alias) : base(HqlSqlWalker.JOIN, "join", factory, new HqlLeft(factory), expression, @alias) + { + } + } + + public class HqlFetch : HqlTreeNode + { + public HqlFetch(IASTFactory factory) : base(HqlSqlWalker.FETCH, "fetch", factory) + { + } + } + + public class HqlLeft : HqlTreeNode + { + public HqlLeft(IASTFactory factory) + : base(HqlSqlWalker.LEFT, "left", factory) + { + } + } + public class HqlAny : HqlBooleanExpression { public HqlAny(IASTFactory factory) : base(HqlSqlWalker.ANY, "any", factory) Added: trunk/nhibernate/src/NHibernate/Linq/Clauses/LeftJoinClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Clauses/LeftJoinClause.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/Clauses/LeftJoinClause.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -0,0 +1,12 @@ +using System.Linq.Expressions; +using Remotion.Data.Linq.Clauses; + +namespace NHibernate.Linq.Visitors +{ + public class LeftJoinClause : AdditionalFromClause + { + public LeftJoinClause(string itemName, System.Type itemType, Expression fromExpression) : base(itemName, itemType, fromExpression) + { + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/GroupBy/NonAggregatingGroupByRewriter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/GroupBy/NonAggregatingGroupByRewriter.cs 2010-02-16 22:50:19 UTC (rev 4944) +++ trunk/nhibernate/src/NHibernate/Linq/GroupBy/NonAggregatingGroupByRewriter.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -96,7 +96,7 @@ } } - internal class ClientSideSelect : ClientSideTransformOperator + public class ClientSideSelect : ClientSideTransformOperator { public LambdaExpression SelectClause { get; private set; } Modified: trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs 2010-02-16 22:50:19 UTC (rev 4944) +++ trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -11,7 +11,7 @@ return new NhQueryable<T>(session); } - public static void ForEach<T>(this IEnumerable<T> query, System.Action<T> method) + public static void ForEach<T>(this IEnumerable<T> query, Action<T> method) { foreach (T item in query) { @@ -26,7 +26,7 @@ public static bool IsNullableOrReference(this System.Type type) { - return !type.IsValueType || (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)); + return !type.IsValueType || type.IsNullable(); } public static System.Type NullableOf(this System.Type type) @@ -34,6 +34,16 @@ return type.GetGenericArguments()[0]; } + public static bool IsPrimitive(this System.Type type) + { + return (type.IsValueType || type.IsNullable() || type == typeof (string)); + } + + public static bool IsNonPrimitive(this System.Type type) + { + return !type.IsPrimitive(); + } + public static T As<T>(this object source) { return (T) source; Modified: trunk/nhibernate/src/NHibernate/Linq/NhLinqExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/NhLinqExpression.cs 2010-02-16 22:50:19 UTC (rev 4944) +++ trunk/nhibernate/src/NHibernate/Linq/NhLinqExpression.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -3,7 +3,6 @@ using System.Linq; using System.Linq.Expressions; using NHibernate.Engine.Query; -using NHibernate.Hql.Ast; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Linq.ResultOperators; using NHibernate.Linq.Visitors; @@ -71,8 +70,11 @@ var queryModel = NhRelinqQueryParser.Parse(_expression); ExpressionToHqlTranslationResults = QueryModelVisitor.GenerateHqlQuery(queryModel, - _constantToParameterMap, - requiredHqlParameters, true); + new VisitorParameters( + sessionFactory, + _constantToParameterMap, + requiredHqlParameters), + true); ParameterDescriptors = requiredHqlParameters.AsReadOnly(); _astNode = ExpressionToHqlTranslationResults.Statement.AstNode; Added: trunk/nhibernate/src/NHibernate/Linq/ReWriters/AddLeftJoinsReWriter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/ReWriters/AddLeftJoinsReWriter.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/ReWriters/AddLeftJoinsReWriter.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using Remotion.Data.Linq; +using Remotion.Data.Linq.Clauses; + +namespace NHibernate.Linq.Visitors +{ + public class AddLeftJoinsReWriter : QueryModelVisitorBase + { + private readonly ISessionFactory _sessionFactory; + + private AddLeftJoinsReWriter(ISessionFactory sessionFactory) + { + _sessionFactory = sessionFactory; + } + + public static void ReWrite(QueryModel queryModel, ISessionFactory sessionFactory) + { + var rewriter = new AddLeftJoinsReWriter(sessionFactory); + + rewriter.VisitQueryModel(queryModel); + } + + public override void VisitSelectClause(SelectClause selectClause, QueryModel queryModel) + { + var joins = LeftJoinDetector.Detect(selectClause.Selector, new NameGenerator(queryModel), _sessionFactory); + + if (joins.Joins.Count > 0) + { + selectClause.Selector = joins.Selector; + + queryModel.TransformExpressions(e => ExpressionSwapper.Swap(e, joins.ExpressionMap)); + + foreach (var join in joins.Joins) + { + queryModel.BodyClauses.Add(join); + } + } + } + } + + public class ExpressionSwapper : NhExpressionTreeVisitor + { + private readonly Dictionary<Expression, Expression> _expressionMap; + + private ExpressionSwapper(Dictionary<Expression, Expression> expressionMap) + { + _expressionMap = expressionMap; + } + + public static Expression Swap(Expression expression, Dictionary<Expression, Expression> expressionMap) + { + var swapper = new ExpressionSwapper(expressionMap); + + return swapper.VisitExpression(expression); + } + + protected override Expression VisitExpression(Expression expression) + { + if (expression == null) + { + return null; + } + + Expression replacement; + + if (_expressionMap.TryGetValue(expression, out replacement)) + { + return replacement; + } + else + { + return base.VisitExpression(expression); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/ReWriters/MergeAggregatingResultsRewriter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/ReWriters/MergeAggregatingResultsRewriter.cs 2010-02-16 22:50:19 UTC (rev 4944) +++ trunk/nhibernate/src/NHibernate/Linq/ReWriters/MergeAggregatingResultsRewriter.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -67,24 +67,27 @@ public override void VisitSelectClause(SelectClause selectClause, QueryModel queryModel) { - selectClause.TransformExpressions(MergeAggregatingResultsInExpressionRewriter.Rewrite); + selectClause.TransformExpressions(e => MergeAggregatingResultsInExpressionRewriter.Rewrite(e, new NameGenerator(queryModel))); } public override void VisitWhereClause(WhereClause whereClause, QueryModel queryModel, int index) { - whereClause.TransformExpressions(MergeAggregatingResultsInExpressionRewriter.Rewrite); + whereClause.TransformExpressions(e => MergeAggregatingResultsInExpressionRewriter.Rewrite(e, new NameGenerator(queryModel))); } } internal class MergeAggregatingResultsInExpressionRewriter : NhExpressionTreeVisitor { - private MergeAggregatingResultsInExpressionRewriter() + private readonly NameGenerator _nameGenerator; + + private MergeAggregatingResultsInExpressionRewriter(NameGenerator nameGenerator) { + _nameGenerator = nameGenerator; } - public static Expression Rewrite(Expression expression) + public static Expression Rewrite(Expression expression, NameGenerator nameGenerator) { - var visitor = new MergeAggregatingResultsInExpressionRewriter(); + var visitor = new MergeAggregatingResultsInExpressionRewriter(nameGenerator); return visitor.VisitExpression(expression); } @@ -131,8 +134,7 @@ private Expression CreateAggregate(Expression fromClauseExpression, LambdaExpression body, Func<Expression,Expression> aggregateFactory, Func<ResultOperatorBase> resultOperatorFactory) { - // TODO - need generated name here - var fromClause = new MainFromClause("x2", body.Parameters[0].Type, fromClauseExpression); + var fromClause = new MainFromClause(_nameGenerator.GetNewName(), body.Parameters[0].Type, fromClauseExpression); var selectClause = body.Body; selectClause = ReplacingExpressionTreeVisitor.Replace(body.Parameters[0], new QuerySourceReferenceExpression( Modified: trunk/nhibernate/src/NHibernate/Linq/ResultTransformer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/ResultTransformer.cs 2010-02-16 22:50:19 UTC (rev 4944) +++ trunk/nhibernate/src/NHibernate/Linq/ResultTransformer.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Linq; -using System.Linq.Expressions; using NHibernate.Transform; namespace NHibernate.Linq Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/EqualityHqlGenerator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/EqualityHqlGenerator.cs 2010-02-16 22:50:19 UTC (rev 4944) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/EqualityHqlGenerator.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq.Expressions; -using NHibernate.Engine.Query; using NHibernate.Hql.Ast; namespace NHibernate.Linq.Visitors @@ -12,29 +10,22 @@ public class EqualityHqlGenerator { private readonly HqlTreeBuilder _hqlTreeBuilder; - private readonly IDictionary<ConstantExpression, NamedParameter> _parameters; - private readonly IList<NamedParameterDescriptor> _requiredHqlParameters; + private readonly VisitorParameters _parameters; - public EqualityHqlGenerator(IDictionary<ConstantExpression, NamedParameter> parameters, IList<NamedParameterDescriptor> requiredHqlParameters) + public EqualityHqlGenerator(VisitorParameters parameters) { _parameters = parameters; - _requiredHqlParameters = requiredHqlParameters; _hqlTreeBuilder = new HqlTreeBuilder(); } public HqlBooleanExpression Visit(Expression innerKeySelector, Expression outerKeySelector) { - if (innerKeySelector is NewExpression && outerKeySelector is NewExpression) - { - return VisitNew((NewExpression)innerKeySelector, (NewExpression)outerKeySelector); - } - else - { - return GenerateEqualityNode(innerKeySelector, outerKeySelector); - } + return innerKeySelector is NewExpression && outerKeySelector is NewExpression + ? VisitNew((NewExpression) innerKeySelector, (NewExpression) outerKeySelector) + : GenerateEqualityNode(innerKeySelector, outerKeySelector); } - private HqlBooleanExpression VisitNew(NewExpression innerKeySelector, NewExpression outerKeySelector) + private HqlBooleanExpression VisitNew(NewExpression innerKeySelector, NewExpression outerKeySelector) { if (innerKeySelector.Arguments.Count != outerKeySelector.Arguments.Count) { @@ -59,8 +50,8 @@ private HqlEquality GenerateEqualityNode(Expression leftExpr, Expression rightExpr) { // TODO - why two visitors? Can't we just reuse? - var left = new HqlGeneratorExpressionTreeVisitor(_parameters, _requiredHqlParameters); - var right = new HqlGeneratorExpressionTreeVisitor(_parameters, _requiredHqlParameters); + var left = new HqlGeneratorExpressionTreeVisitor(_parameters); + var right = new HqlGeneratorExpressionTreeVisitor(_parameters); return _hqlTreeBuilder.Equality(left.Visit(leftExpr).AsExpression(), right.Visit(rightExpr).AsExpression()); } Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-02-16 22:50:19 UTC (rev 4944) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Linq.Expressions; using NHibernate.Engine.Query; using NHibernate.Hql.Ast; @@ -13,21 +11,19 @@ public class HqlGeneratorExpressionTreeVisitor : IHqlExpressionVisitor { private readonly HqlTreeBuilder _hqlTreeBuilder; - private readonly IDictionary<ConstantExpression, NamedParameter> _parameters; - private readonly IList<NamedParameterDescriptor> _requiredHqlParameters; + private readonly VisitorParameters _parameters; static private readonly FunctionRegistry FunctionRegistry = FunctionRegistry.Initialise(); - public static HqlTreeNode Visit(Expression expression, IDictionary<ConstantExpression, NamedParameter> parameters, IList<NamedParameterDescriptor> requiredHqlParameters) + public static HqlTreeNode Visit(Expression expression, VisitorParameters parameters) { - var visitor = new HqlGeneratorExpressionTreeVisitor(parameters, requiredHqlParameters); + var visitor = new HqlGeneratorExpressionTreeVisitor(parameters); return visitor.VisitExpression(expression); } - public HqlGeneratorExpressionTreeVisitor(IDictionary<ConstantExpression, NamedParameter> parameters, IList<NamedParameterDescriptor> requiredHqlParameters) + public HqlGeneratorExpressionTreeVisitor(VisitorParameters parameters) { - _parameters = parameters; - _requiredHqlParameters = requiredHqlParameters; + _parameters = parameters; _hqlTreeBuilder = new HqlTreeBuilder(); } @@ -184,7 +180,7 @@ protected HqlTreeNode VisitNhDistinct(NhDistinctExpression expression) { - var visitor = new HqlGeneratorExpressionTreeVisitor(_parameters, _requiredHqlParameters); + var visitor = new HqlGeneratorExpressionTreeVisitor(_parameters); return _hqlTreeBuilder.DistinctHolder( _hqlTreeBuilder.Distinct(), @@ -367,9 +363,9 @@ NamedParameter namedParameter; - if (_parameters.TryGetValue(expression, out namedParameter)) + if (_parameters.ConstantToParameterMap.TryGetValue(expression, out namedParameter)) { - _requiredHqlParameters.Add(new NamedParameterDescriptor(namedParameter.Name, null, new[] { _requiredHqlParameters.Count + 1 }, false)); + _parameters.RequiredHqlParameters.Add(new NamedParameterDescriptor(namedParameter.Name, null, new[] { _parameters.RequiredHqlParameters.Count + 1 }, false)); if (namedParameter.Value is bool) { @@ -415,7 +411,7 @@ protected HqlTreeNode VisitSubQueryExpression(SubQueryExpression expression) { - ExpressionToHqlTranslationResults query = QueryModelVisitor.GenerateHqlQuery(expression.QueryModel, _parameters, _requiredHqlParameters, false); + ExpressionToHqlTranslationResults query = QueryModelVisitor.GenerateHqlQuery(expression.QueryModel, _parameters, false); return query.Statement; } Added: trunk/nhibernate/src/NHibernate/Linq/Visitors/LeftJoinDetector.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/LeftJoinDetector.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/LeftJoinDetector.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -0,0 +1,74 @@ +using System.Collections.Generic; +using System.Linq.Expressions; +using Remotion.Data.Linq.Clauses.Expressions; + +namespace NHibernate.Linq.Visitors +{ + public class LeftJoinDetector : NhExpressionTreeVisitor + { + private readonly NameGenerator _nameGenerator; + private readonly ISessionFactory _sessionFactory; + private readonly Dictionary<string, LeftJoinClause> _joins = new Dictionary<string, LeftJoinClause>(); + private readonly Dictionary<Expression, Expression> _expressionMap = new Dictionary<Expression, Expression>(); + + private LeftJoinDetector(NameGenerator nameGenerator, ISessionFactory sessionFactory) + { + _nameGenerator = nameGenerator; + _sessionFactory = sessionFactory; + } + + public static Results Detect(Expression selector, NameGenerator nameGenerator, ISessionFactory sessionFactory) + { + var detector = new LeftJoinDetector(nameGenerator, sessionFactory); + + var newSelector = detector.VisitExpression(selector); + + return new Results(newSelector, detector._joins.Values, detector._expressionMap); + } + + protected override Expression VisitMemberExpression(MemberExpression expression) + { + if (expression.Type.IsNonPrimitive() && IsEntity(expression.Type)) + { + var newExpr = AddJoin(expression); + _expressionMap.Add(expression, newExpr); + return newExpr; + } + + return base.VisitMemberExpression(expression); + } + + private bool IsEntity(System.Type type) + { + return _sessionFactory.GetClassMetadata(type) != null; + } + + private Expression AddJoin(MemberExpression expression) + { + string key = ExpressionKeyVisitor.Visit(expression, null); + LeftJoinClause join; + + if (!_joins.TryGetValue(key, out join)) + { + join = new LeftJoinClause(_nameGenerator.GetNewName(), expression.Type, expression); + _joins.Add(key, join); + } + + return new QuerySourceReferenceExpression(join); + } + + public class Results + { + public Expression Selector { get; private set; } + public ICollection<LeftJoinClause> Joins { get; private set; } + public Dictionary<Expression, Expression> ExpressionMap { get; private set; } + + public Results(Expression selector, ICollection<LeftJoinClause> joins, Dictionary<Expression, Expression> expressionMap) + { + Selector = selector; + Joins = joins; + ExpressionMap = expressionMap; + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/Visitors/NameGenerator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/NameGenerator.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/NameGenerator.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -0,0 +1,19 @@ +using Remotion.Data.Linq; + +namespace NHibernate.Linq.Visitors +{ + public class NameGenerator + { + private readonly QueryModel _model; + + public NameGenerator(QueryModel model) + { + _model = model; + } + + public string GetNewName() + { + return _model.GetNewName("_"); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs 2010-02-16 22:50:19 UTC (rev 4944) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -1,15 +1,13 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; -using System.Reflection; -using NHibernate.Engine.Query; using NHibernate.Hql.Ast; using NHibernate.Linq.GroupBy; using NHibernate.Linq.GroupJoin; using NHibernate.Linq.ResultOperators; using NHibernate.Linq.ReWriters; +using NHibernate.Linq.Visitors.ResultOperatorProcessors; using NHibernate.Type; using Remotion.Data.Linq; using Remotion.Data.Linq.Clauses; @@ -21,7 +19,7 @@ { public class QueryModelVisitor : QueryModelVisitorBase { - public static ExpressionToHqlTranslationResults GenerateHqlQuery(QueryModel queryModel, IDictionary<ConstantExpression, NamedParameter> parameters, IList<NamedParameterDescriptor> requiredHqlParameters, bool root) + public static ExpressionToHqlTranslationResults GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, bool root) { // Remove unnecessary body operators RemoveUnnecessaryBodyOperators.ReWrite(queryModel); @@ -44,47 +42,71 @@ // Flatten pointless subqueries QueryReferenceExpressionFlattener.ReWrite(queryModel); - var visitor = new QueryModelVisitor(parameters, requiredHqlParameters, root); - visitor.VisitQueryModel(queryModel); + // Add left joins for references + AddLeftJoinsReWriter.ReWrite(queryModel, parameters.SessionFactory); + var visitor = new QueryModelVisitor(parameters, root, queryModel); + visitor.Visit(); + return visitor.GetTranslation(); } - private readonly HqlTreeBuilder _hqlTreeBuilder; + private static readonly ResultOperatorMap ResultOperatorMap; private readonly List<Action<IQuery, IDictionary<string, Tuple<object, IType>>>> _additionalCriteria = new List<Action<IQuery, IDictionary<string, Tuple<object, IType>>>>(); private readonly List<LambdaExpression> _listTransformers = new List<LambdaExpression>(); private readonly List<LambdaExpression> _itemTransformers = new List<LambdaExpression>(); private readonly List<LambdaExpression> _postExecuteTransformers = new List<LambdaExpression>(); - - private IStreamedDataInfo _previousEvaluationType; - private IStreamedDataInfo _currentEvaluationType; - - private readonly IDictionary<ConstantExpression, NamedParameter> _parameters; - private readonly IList<NamedParameterDescriptor> _requiredHqlParameters; private readonly bool _root; private bool _serverSide = true; - private HqlTreeNode _treeNode; - private System.Type _resultType; + public HqlTreeNode Root { get; private set; } + public VisitorParameters VisitorParameters { get; private set; } + public IStreamedDataInfo CurrentEvaluationType { get; private set; } + public IStreamedDataInfo PreviousEvaluationType { get; private set; } + public HqlTreeBuilder TreeBuilder { get; private set; } + public QueryModel Model { get; private set; } - private QueryModelVisitor(IDictionary<ConstantExpression, NamedParameter> parameters, IList<NamedParameterDescriptor> requiredHqlParameters, bool root) + static QueryModelVisitor() + { + ResultOperatorMap = new ResultOperatorMap(); + + ResultOperatorMap.Add<AggregateResultOperator, ProcessAggregate>(); + ResultOperatorMap.Add<FirstResultOperator, ProcessFirst>(); + ResultOperatorMap.Add<TakeResultOperator, ProcessTake>(); + ResultOperatorMap.Add<SkipResultOperator, ProcessSkip>(); + ResultOperatorMap.Add<GroupResultOperator, ProcessGroupBy>(); + ResultOperatorMap.Add<SingleResultOperator, ProcessSingle>(); + ResultOperatorMap.Add<ContainsResultOperator, ProcessContains>(); + ResultOperatorMap.Add<NonAggregatingGroupBy, ProcessNonAggregatingGroupBy>(); + ResultOperatorMap.Add<ClientSideSelect, ProcessClientSideSelect>(); + ResultOperatorMap.Add<AnyResultOperator, ProcessAny>(); + ResultOperatorMap.Add<AllResultOperator, ProcessAll>(); + } + + private QueryModelVisitor(VisitorParameters visitorParameters, bool root, QueryModel queryModel) { - _parameters = parameters; - _requiredHqlParameters = requiredHqlParameters; + VisitorParameters = visitorParameters; + Model = queryModel; _root = root; - _hqlTreeBuilder = new HqlTreeBuilder(); - _treeNode = _hqlTreeBuilder.Query(_hqlTreeBuilder.SelectFrom(_hqlTreeBuilder.From())); + TreeBuilder = new HqlTreeBuilder(); + Root = TreeBuilder.Query(TreeBuilder.SelectFrom(TreeBuilder.From())); } - public ExpressionToHqlTranslationResults GetTranslation() + private void Visit() + { + VisitQueryModel(Model); + } + + + private ExpressionToHqlTranslationResults GetTranslation() { if (_root) { DetectOuterExists(); } - return new ExpressionToHqlTranslationResults(_treeNode, + return new ExpressionToHqlTranslationResults(Root, _itemTransformers, _listTransformers, _postExecuteTransformers, @@ -93,9 +115,9 @@ private void DetectOuterExists() { - if (_treeNode is HqlExists) + if (Root is HqlExists) { - _treeNode = _treeNode.Children.First(); + Root = Root.Children.First(); _additionalCriteria.Add((q, p) => q.SetMaxResults(1)); @@ -107,9 +129,9 @@ public override void VisitMainFromClause(MainFromClause fromClause, QueryModel queryModel) { - AddFromClause(_hqlTreeBuilder.Range( - HqlGeneratorExpressionTreeVisitor.Visit(fromClause.FromExpression, _parameters, _requiredHqlParameters), - _hqlTreeBuilder.Alias(fromClause.ItemName))); + AddFromClause(TreeBuilder.Range( + HqlGeneratorExpressionTreeVisitor.Visit(fromClause.FromExpression, VisitorParameters), + TreeBuilder.Alias(fromClause.ItemName))); base.VisitMainFromClause(fromClause, queryModel); } @@ -117,56 +139,55 @@ private void AddWhereClause(HqlBooleanExpression where) { - var currentWhere = _treeNode.NodesPreOrder.Where(n => n is HqlWhere).FirstOrDefault(); + var currentWhere = Root.NodesPreOrder.Where(n => n is HqlWhere).FirstOrDefault(); if (currentWhere == null) { - currentWhere = _hqlTreeBuilder.Where(where); - _treeNode.As<HqlQuery>().AddChild(currentWhere); + currentWhere = TreeBuilder.Where(where); + Root.As<HqlQuery>().AddChild(currentWhere); } else { var currentClause = (HqlBooleanExpression)currentWhere.Children.Single(); currentWhere.ClearChildren(); - currentWhere.AddChild(_hqlTreeBuilder.BooleanAnd(currentClause, where)); + currentWhere.AddChild(TreeBuilder.BooleanAnd(currentClause, where)); } } private void AddFromClause(HqlTreeNode from) { - _treeNode.NodesPreOrder.Where(n => n is HqlFrom).First().AddChild(from); + Root.NodesPreOrder.Where(n => n is HqlFrom).First().AddChild(from); } private void AddSelectClause(HqlTreeNode select) { - _treeNode.NodesPreOrder.Where(n => n is HqlSelectFrom).First().AddChild(select); + Root.NodesPreOrder.Where(n => n is HqlSelectFrom).First().AddChild(select); } private void AddGroupByClause(HqlGroupBy groupBy) { - _treeNode.As<HqlQuery>().AddChild(groupBy); + Root.As<HqlQuery>().AddChild(groupBy); } private void AddOrderByClause(HqlExpression orderBy, HqlDirectionStatement direction) { - var orderByRoot = _treeNode.NodesPreOrder.Where(n => n is HqlOrderBy).FirstOrDefault(); + var orderByRoot = Root.NodesPreOrder.Where(n => n is HqlOrderBy).FirstOrDefault(); if (orderByRoot == null) { - orderByRoot = _hqlTreeBuilder.OrderBy(); - _treeNode.As<HqlQuery>().AddChild(orderByRoot); + orderByRoot = TreeBuilder.OrderBy(); + Root.As<HqlQuery>().AddChild(orderByRoot); } orderByRoot.AddChild(orderBy); orderByRoot.AddChild(direction); } - public override void VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, int index) { - _previousEvaluationType = _currentEvaluationType; - _currentEvaluationType = resultOperator.GetOutputDataInfo(_previousEvaluationType); + PreviousEvaluationType = CurrentEvaluationType; + CurrentEvaluationType = resultOperator.GetOutputDataInfo(PreviousEvaluationType); if (resultOperator is ClientSideTransformOperator) { @@ -180,270 +201,34 @@ } } - if (resultOperator is FirstResultOperator) - { - ProcessFirstOperator((FirstResultOperator) resultOperator); - } - else if (resultOperator is TakeResultOperator) - { - ProcessTakeOperator((TakeResultOperator)resultOperator); - } - else if (resultOperator is SkipResultOperator) - { - ProcessSkipOperator((SkipResultOperator)resultOperator); - } - else if (resultOperator is GroupResultOperator) - { - ProcessGroupByOperator((GroupResultOperator)resultOperator); - } - else if (resultOperator is SingleResultOperator) - { - ProcessSingleOperator((SingleResultOperator) resultOperator); - } - else if (resultOperator is ContainsResultOperator) - { - ProcessContainsOperator((ContainsResultOperator) resultOperator); - } - else if (resultOperator is NonAggregatingGroupBy) - { - ProcessNonAggregatingGroupBy((NonAggregatingGroupBy)resultOperator, queryModel); - } - else if (resultOperator is ClientSideSelect) - { - ProcessClientSideSelect((ClientSideSelect)resultOperator); - } - else if (resultOperator is AggregateResultOperator) - { - ProcessAggregateOperator((AggregateResultOperator)resultOperator); - } - else if (resultOperator is AnyResultOperator) - { - ProcessAnyOperator((AnyResultOperator) resultOperator); - } - else if (resultOperator is AllResultOperator) - { - ProcessAllOperator((AllResultOperator) resultOperator); - } - else - { - throw new NotSupportedException(string.Format("The {0} result operator is not current supported", - resultOperator.GetType().Name)); - } - } + var results = ResultOperatorMap.Process(resultOperator, this); - private void ProcessAllOperator(AllResultOperator resultOperator) - { - AddWhereClause(_hqlTreeBuilder.BooleanNot( - HqlGeneratorExpressionTreeVisitor.Visit(resultOperator.Predicate, _parameters, - _requiredHqlParameters).AsBooleanExpression())); - - _treeNode = _hqlTreeBuilder.BooleanNot(_hqlTreeBuilder.Exists((HqlQuery)_treeNode)); - } - - private void ProcessAnyOperator(AnyResultOperator anyOperator) - { - _treeNode = _hqlTreeBuilder.Exists((HqlQuery) _treeNode); - } - - private void ProcessContainsOperator(ContainsResultOperator resultOperator) - { - var itemExpression = - HqlGeneratorExpressionTreeVisitor.Visit(resultOperator.Item, _parameters, _requiredHqlParameters) - .AsExpression(); - - var from = GetFromRangeClause(); - var source = from.Children.First(); - - if (source is HqlParameter) + if (results.AdditionalCriteria != null) { - // This is an "in" style statement - _treeNode = _hqlTreeBuilder.In(itemExpression, source); - + _additionalCriteria.Add(results.AdditionalCriteria); } - else + if (results.GroupBy != null) { - // This is an "exists" style statement - AddWhereClause(_hqlTreeBuilder.Equality( - _hqlTreeBuilder.Ident(GetFromAlias().AstNode.Text), - itemExpression)); - - _treeNode = _hqlTreeBuilder.Exists((HqlQuery)_treeNode); + AddGroupByClause(results.GroupBy); } - } - - private HqlAlias GetFromAlias() - { - return _treeNode.NodesPreOrder.Single(n => n is HqlRange).Children.Single(n => n is HqlAlias) as HqlAlias; - } - - private HqlRange GetFromRangeClause() - { - return _treeNode.NodesPreOrder.Single(n => n is HqlRange).As<HqlRange>(); - } - - private void ProcessAggregateOperator(AggregateResultOperator resultOperator) - { - var inputType = resultOperator.Accumulator.Parameters[1].Type; - var accumulatorType = resultOperator.Accumulator.Parameters[0].Type; - var inputList = Expression.Parameter(typeof(IEnumerable<>).MakeGenericType(typeof(object)), "inputList"); - - var castToItem = EnumerableHelper.GetMethod("Cast", new[] { typeof(IEnumerable) }, new[] { inputType }); - var castToItemExpr = Expression.Call(castToItem, inputList); - - MethodCallExpression call; - - if (resultOperator.ParseInfo.ParsedExpression.Arguments.Count == 2) + if (results.ListTransformer != null) { - var aggregate = ReflectionHelper.GetMethod(() => Enumerable.Aggregate<object>(null, null)); - aggregate = aggregate.GetGenericMethodDefinition().MakeGenericMethod(inputType); - - call = Expression.Call( - aggregate, - castToItemExpr, - resultOperator.Accumulator - ); - + _listTransformers.Add(results.ListTransformer); } - else if (resultOperator.ParseInfo.ParsedExpression.Arguments.Count == 3) + if (results.PostExecuteTransformer != null) { - var aggregate = ReflectionHelper.GetMethod(() => Enumerable.Aggregate<object, object>(null, null, null)); - aggregate = aggregate.GetGenericMethodDefinition().MakeGenericMethod(inputType, accumulatorType); - - call = Expression.Call( - aggregate, - castToItemExpr, - resultOperator.OptionalSeed, - resultOperator.Accumulator - ); + _postExecuteTransformers.Add(results.PostExecuteTransformer); } - else + if (results.WhereClause != null) { - var selectorType = resultOperator.OptionalSelector.Type.GetGenericArguments()[2]; - var aggregate = ReflectionHelper.GetMethod(() => Enumerable.Aggregate<object, object, object>(null, null, null, null)); - aggregate = aggregate.GetGenericMethodDefinition().MakeGenericMethod(inputType, accumulatorType, selectorType); - - call = Expression.Call( - aggregate, - castToItemExpr, - resultOperator.OptionalSeed, - resultOperator.Accumulator, - resultOperator.OptionalSelector - ); + AddWhereClause(results.WhereClause); } - - _listTransformers.Add(Expression.Lambda(call, inputList)); - } - - private void ProcessClientSideSelect(ClientSideSelect resultOperator) - { - var inputType = resultOperator.SelectClause.Parameters[0].Type; - var outputType = resultOperator.SelectClause.Type.GetGenericArguments()[1]; - - var inputList = Expression.Parameter(typeof (IEnumerable<>).MakeGenericType(inputType), "inputList"); - - var selectMethod = EnumerableHelper.GetMethod("Select", new[] { typeof(IEnumerable<>), typeof(Func<,>) }, new[] { inputType, outputType }); - var toListMethod = EnumerableHelper.GetMethod("ToList", new[] {typeof (IEnumerable<>)}, new[] {outputType}); - - var lambda = Expression.Lambda( - Expression.Call(toListMethod, - Expression.Call(selectMethod, inputList, resultOperator.SelectClause)), - inputList); - - _listTransformers.Add(lambda); - } - - private void ProcessTakeOperator(TakeResultOperator resultOperator) - { - NamedParameter parameterName; - - // TODO - very similar to ProcessSkip, plus want to investigate the scenario in the "else" - // clause to see if it is valid - if (_parameters.TryGetValue(resultOperator.Count as ConstantExpression, out parameterName)) + if (results.TreeNode != null) { - _additionalCriteria.Add((q, p) => q.SetMaxResults((int) p[parameterName.Name].First)); + Root = results.TreeNode; } - else - { - _additionalCriteria.Add((q, p) => q.SetMaxResults(resultOperator.GetConstantCount())); - } - } - - private void ProcessSkipOperator(SkipResultOperator resultOperator) - { - NamedParameter parameterName; - - if (_parameters.TryGetValue(resultOperator.Count as ConstantExpression, out parameterName)) - { - _additionalCriteria.Add((q, p) => q.SetFirstResult((int)p[parameterName.Name].First)); - } - else - { - _additionalCriteria.Add((q, p) => q.SetFirstResult(resultOperator.GetConstantCount())); - } } - private void ProcessNonAggregatingGroupBy(NonAggregatingGroupBy resultOperator, QueryModel model) - { - var tSource = model.SelectClause.Selector.Type; - var tKey = resultOperator.GroupBy.KeySelector.Type; - var tElement = resultOperator.GroupBy.ElementSelector.Type; - - // Stuff in the group by that doesn't map to HQL. Run it client-side - var listParameter = Expression.Parameter(typeof (IEnumerable<object>), "list"); - - ParameterExpression itemParam = Expression.Parameter(tSource, "item"); - Expression keySelectorSource = itemParam; - - if (tSource != SourceOf(resultOperator.GroupBy.KeySelector)) - { - keySelectorSource = Expression.MakeMemberAccess(itemParam, - tSource.GetMember( - ((QuerySourceReferenceExpression) - resultOperator.GroupBy.KeySelector).ReferencedQuerySource. - ItemName)[0]); - } - - - Expression keySelector = new GroupByKeySelectorVisitor(keySelectorSource).Visit(resultOperator.GroupBy.KeySelector); - - Expression elementSelectorSource = itemParam; - - if (tSource != SourceOf(resultOperator.GroupBy.ElementSelector)) - { - elementSelectorSource = Expression.MakeMemberAccess(itemParam, - tSource.GetMember( - ((QuerySourceReferenceExpression) - resultOperator.GroupBy.ElementSelector).ReferencedQuerySource. - ItemName)[0]); - } - - Expression elementSelector = new GroupByKeySelectorVisitor(elementSelectorSource).Visit(resultOperator.GroupBy.ElementSelector); - - var groupByMethod = EnumerableHelper.GetMethod("GroupBy", - new[] { typeof(IEnumerable<>), typeof(Func<,>), typeof(Func<,>) }, - new[] { tSource, tKey, tElement }); - - var castToItem = EnumerableHelper.GetMethod("Cast", new[] { typeof(IEnumerable) }, new[] { tSource }); - - var toList = EnumerableHelper.GetMethod("ToList", new [] { typeof(IEnumerable<>)}, new [] {resultOperator.GroupBy.ItemType}); - - LambdaExpression keySelectorExpr = Expression.Lambda(keySelector, itemParam); - - LambdaExpression elementSelectorExpr = Expression.Lambda(elementSelector, itemParam); - - Expression castToItemExpr = Expression.Call(castToItem, listParameter); - - var groupByExpr = Expression.Call(groupByMethod, castToItemExpr, keySelectorExpr, elementSelectorExpr); - - var toListExpr = Expression.Call(toList, groupByExpr); - - var lambdaExpr = Expression.Lambda(toListExpr, listParameter); - - _listTransformers.Add(lambdaExpr); - - return; - } - private void GroupBy<TSource, TKey, TResult>(Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TResult>> elementSelector) { IQueryable<object> list = null; @@ -451,55 +236,11 @@ var x = list.Cast<TSource>().GroupBy(keySelector, elementSelector); } - private static System.Type SourceOf(Expression keySelector) - { - return new GroupByKeySourceFinder().Visit(keySelector).Type; - } - - private void ProcessGroupByOperator(GroupResultOperator resultOperator) - { - AddGroupByClause(_hqlTreeBuilder.GroupBy(HqlGeneratorExpressionTreeVisitor.Visit(resultOperator.KeySelector, _parameters, _requiredHqlParameters).AsExpression())); - } - - private void ProcessFirstOperator(FirstResultOperator resultOperator) - { - var firstMethod = resultOperator.ReturnDefaultWhenEmpty - ? ReflectionHelper.GetMethod(() => Queryable.FirstOrDefault<object>(null)) - : ReflectionHelper.GetMethod(() => Queryable.First<object>(null)); - - ProcessFirstOrSingle(firstMethod); - } - - private void ProcessSingleOperator(SingleResultOperator resultOperator) - { - var firstMethod = resultOperator.ReturnDefaultWhenEmpty - ? ReflectionHelper.GetMethod(() => Queryable.SingleOrDefault<object>(null)) - : ReflectionHelper.GetMethod(() => Queryable.Single<object>(null)); - - ProcessFirstOrSingle(firstMethod); - } - - private void ProcessFirstOrSingle(MethodInfo target) - { - target = target.MakeGenericMethod(_currentEvaluationType.DataType); - - var parameter = Expression.Parameter(_previousEvaluationType.DataType, null); - - var lambda = Expression.Lambda( - Expression.Call( - target, - parameter), - parameter); - - _additionalCriteria.Add((q, p) => q.SetMaxResults(1)); - _postExecuteTransformers.Add(lambda); - } - public override void VisitSelectClause(SelectClause selectClause, QueryModel queryModel) { - _currentEvaluationType = selectClause.GetOutputDataInfo(); + CurrentEvaluationType = selectClause.GetOutputDataInfo(); - var visitor = new SelectClauseVisitor(typeof(object[]), _parameters, _requiredHqlParameters); + var visitor = new SelectClauseVisitor(typeof(object[]), VisitorParameters); visitor.Visit(selectClause.Selector); @@ -508,7 +249,7 @@ _itemTransformers.Add(visitor.ProjectionExpression); } - AddSelectClause(_hqlTreeBuilder.Select(visitor.GetHqlNodes())); + AddSelectClause(TreeBuilder.Select(visitor.GetHqlNodes())); base.VisitSelectClause(selectClause, queryModel); } @@ -516,43 +257,50 @@ public override void VisitWhereClause(WhereClause whereClause, QueryModel queryModel, int index) { // Visit the predicate to build the query - AddWhereClause(HqlGeneratorExpressionTreeVisitor.Visit(whereClause.Predicate, _parameters, _requiredHqlParameters).AsBooleanExpression()); + AddWhereClause(HqlGeneratorExpressionTreeVisitor.Visit(whereClause.Predicate, VisitorParameters).AsBooleanExpression()); } public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index) { foreach (Ordering clause in orderByClause.Orderings) { - AddOrderByClause(HqlGeneratorExpressionTreeVisitor.Visit(clause.Expression, _parameters, _requiredHqlParameters).AsExpression(), + AddOrderByClause(HqlGeneratorExpressionTreeVisitor.Visit(clause.Expression, VisitorParameters).AsExpression(), clause.OrderingDirection == OrderingDirection.Asc - ? _hqlTreeBuilder.Ascending() - : (HqlDirectionStatement) _hqlTreeBuilder.Descending()); + ? TreeBuilder.Ascending() + : (HqlDirectionStatement) TreeBuilder.Descending()); } } public override void VisitJoinClause(JoinClause joinClause, QueryModel queryModel, int index) { - var equalityVisitor = new EqualityHqlGenerator(_parameters, _requiredHqlParameters); + var equalityVisitor = new EqualityHqlGenerator(VisitorParameters); var whereClause = equalityVisitor.Visit(joinClause.InnerKeySelector, joinClause.OuterKeySelector); AddWhereClause(whereClause); - AddFromClause(_hqlTreeBuilder.Range(HqlGeneratorExpressionTreeVisitor.Visit(joinClause.InnerSequence, _parameters, _requiredHqlParameters), - _hqlTreeBuilder.Alias(joinClause.ItemName))); + AddFromClause(TreeBuilder.Range(HqlGeneratorExpressionTreeVisitor.Visit(joinClause.InnerSequence, VisitorParameters), + TreeBuilder.Alias(joinClause.ItemName))); } public override void VisitAdditionalFromClause(AdditionalFromClause fromClause, QueryModel queryModel, int index) { - if (fromClause.FromExpression is MemberExpression) + if (fromClause is LeftJoinClause) + { + // It's a left join + AddFromClause(TreeBuilder.LeftJoin( + HqlGeneratorExpressionTreeVisitor.Visit(fromClause.FromExpression, VisitorParameters).AsExpression(), + TreeBuilder.Alias(fromClause.ItemName))); + } + else if (fromClause.FromExpression is MemberExpression) { var member = (MemberExpression) fromClause.FromExpression; if (member.Expression is QuerySourceReferenceExpression) { // It's a join - AddFromClause(_hqlTreeBuilder.Join( - HqlGeneratorExpressionTreeVisitor.Visit(fromClause.FromExpression, _parameters, _requiredHqlParameters).AsExpression(), - _hqlTreeBuilder.Alias(fromClause.ItemName))); + AddFromClause(TreeBuilder.Join( + HqlGeneratorExpressionTreeVisitor.Visit(fromClause.FromExpression, VisitorParameters).AsExpression(), + TreeBuilder.Alias(fromClause.ItemName))); } else { @@ -563,9 +311,9 @@ else { // TODO - exact same code as in MainFromClause; refactor this out - AddFromClause(_hqlTreeBuilder.Range( - HqlGeneratorExpressionTreeVisitor.Visit(fromClause.FromExpression, _parameters, _requiredHqlParameters), - _hqlTreeBuilder.Alias(fromClause.ItemName))); + AddFromClause(TreeBuilder.Range( + HqlGeneratorExpressionTreeVisitor.Visit(fromClause.FromExpression, VisitorParameters), + TreeBuilder.Alias(fromClause.ItemName))); } @@ -576,11 +324,5 @@ { throw new NotImplementedException(); } - - internal enum ResultOperatorProcessingMode - { - ProcessServerSide, - ProcessClientSide - } } } \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/IResultOperatorProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/IResultOperatorProcessor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/IResultOperatorProcessor.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -0,0 +1,7 @@ +namespace NHibernate.Linq.Visitors.ResultOperatorProcessors +{ + public interface IResultOperatorProcessor<T> + { + ProcessResultOperatorReturn Process(T resultOperator, QueryModelVisitor queryModelVisitor); + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAggregate.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAggregate.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessAggregate.cs 2010-02-24 15:52:13 UTC (rev 4945) @@ -0,0 +1,63 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; + +namespace NHibernate.Linq.Visitors.ResultOperatorProcessors +{ + public class ProcessAggregate : IResultOperatorProcessor<AggregateResultOperator> + { + public ProcessResultOperatorReturn Process(AggregateResultOperator resultOperator, QueryModelVisitor queryModelVisitor) + { + var inputType = resultOperator.Accumulator.Parameters[1].Type; + var accumulatorType = resultOperator.Accumulator.Parameters[0].Type; + var inputList = Expression.Parameter(typeof(IEnumerable<>).MakeGenericType(typeof(object)), "inputList"); + + var castToItem = EnumerableHelper.GetMethod("Cast", new[] { typeof(IEnumerable) }, new[] { inputType }); + var castToItemExpr = Expression.Call(castToItem, inputList); + + MethodCallExpression call; + + if (resultOperator.ParseInfo.ParsedExpression.Arguments.Count == 2) + { + var aggregate = ReflectionHelper.GetMethod(() => Enumerable.Aggregate<object>(null, null)); + aggregate = aggregate.GetGenericMethodDefinition().MakeGenericMethod(inputType); + + call = Expression.Call( + aggregate, + castToItemExpr, + resultOperator.Accumulator + ); + + } + else if (resultOperator.ParseInfo.ParsedExpression.Arguments.Count == 3) + { + var aggregate = ReflectionHelper.GetMethod(() => Enumerable.Aggregate<object, object>(null, null, null)); + aggregate = aggregate.GetGenericMethodDefinition().MakeGenericMethod(inputType, accumulatorType); + + call = Expression.Call( + aggregate, + castToItemExpr, + resultOperator.OptionalSeed, + resultOperator.Accumulator + ); + } + else + { + var selectorType = resultOperator.OptionalSelector.Type.GetGenericArguments()[2]; + var aggregate = ReflectionHelper.GetMethod(() => Enumerable.Aggregate<object, object, object>(null, null, null, null)); + aggregate = aggregate.GetGenericMethodDefinition().MakeGenericMethod(inputType, accumulatorType, selectorType); + + call = Expression.Call( + aggregate, + castToItemExpr, + resultOperator.OptionalSeed, + resultOperator.Accumulator, + resultOperator.OptionalSelector + ... [truncated message content] |
From: <ric...@us...> - 2010-02-16 22:50:26
|
Revision: 4944 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4944&view=rev Author: ricbrown Date: 2010-02-16 22:50:19 +0000 (Tue, 16 Feb 2010) Log Message: ----------- Fix NH-1981 (Multiple SQL parameters generated for same HQL parameter) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs trunk/nhibernate/src/NHibernate/Engine/Query/NativeSQLQueryPlan.cs trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionParameterVisitor.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs trunk/nhibernate/src/NHibernate.Test/Linq/RegresstionTests.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlStringFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1981/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1981/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1981/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1981/Model.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2010-02-07 12:15:51 UTC (rev 4943) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2010-02-16 22:50:19 UTC (rev 4944) @@ -50,19 +50,6 @@ { return base.GetLimitString(querySqlString, offset, last); } - // we have to do this in order to support parameters in order clause, the foramt - // that sql 2005 uses for paging means that we move the parameters around, which means, - // that positions are lost, so we record them before making any changes. - // NH-1528 - int parameterPositon = 0; - foreach (var part in querySqlString.Parts) - { - Parameter param = part as Parameter; - if (param == null) - continue; - param.OriginalPositionInQuery = parameterPositon; - parameterPositon += 1; - } int fromIndex = GetFromIndex(querySqlString); SqlString select = querySqlString.Substring(0, fromIndex); Modified: trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs 2010-02-07 12:15:51 UTC (rev 4943) +++ trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs 2010-02-16 22:50:19 UTC (rev 4944) @@ -56,27 +56,8 @@ return; } - string name; + string name = formatter.GetParameterName(parameter.ParameterPosition ?? parameterIndex); - if (queryIndexToNumberOfPreceedingParameters.Count == 0) - { - // there's only one query... no need to worry about indexes of parameters of previous queries - name = formatter.GetParameterName(parameter.OriginalPositionInQuery ?? parameterIndex); - } - else - { - // multiple queries... in case the parameters were switched around (for SQL paging for instance) we need - // to keep the number of preceeding parameters (in previous queries of the batch) into account - if (parameter.OriginalPositionInQuery != null) - { - name = formatter.GetParameterName(GetNumberOfPreceedingParameters() + parameter.OriginalPositionInQuery.Value); - } - else - { - name = formatter.GetParameterName(parameterIndex); - } - } - parameterIndex++; result.Append(name); } Modified: trunk/nhibernate/src/NHibernate/Engine/Query/NativeSQLQueryPlan.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/NativeSQLQueryPlan.cs 2010-02-07 12:15:51 UTC (rev 4943) +++ trunk/nhibernate/src/NHibernate/Engine/Query/NativeSQLQueryPlan.cs 2010-02-16 22:50:19 UTC (rev 4944) @@ -86,7 +86,7 @@ { queryParameters.ProcessFilters(customQuery.SQL, session); SqlString sql = queryParameters.FilteredSQL; - SqlType[] sqlTypes = GetParameterTypes(queryParameters, session); + SqlType[] sqlTypes = queryParameters.PrepareParameterTypes(sql, session.Factory, GetNamedParameterLocs, 0, false, false); IDbCommand ps = session.Batcher.PrepareCommand(CommandType.Text, sql, sqlTypes); @@ -102,7 +102,7 @@ // The responsibility of parameter binding was entirely moved to QueryParameters // to deal with positionslParameter+NamedParameter+ParameterOfFilters - queryParameters.BindParameters(ps, GetNamedParameterLocs, 0, session); + queryParameters.BindParameters(ps, 0, session); result = session.Batcher.ExecuteNonQuery(ps); } finally @@ -125,52 +125,5 @@ return result; } - - private SqlType[] GetParameterTypes(QueryParameters parameters, ISessionImplementor session) - { - List<IType> paramTypeList = new List<IType>(); - int span = 0; - - foreach (IType type in parameters.PositionalParameterTypes) - { - paramTypeList.Add(type); - span += type.GetColumnSpan(session.Factory); - } - - if (parameters.NamedParameters != null && parameters.NamedParameters.Count > 0) - { - int offset = paramTypeList.Count; - - // convert the named parameters to an array of types - foreach (KeyValuePair<string, TypedValue> e in parameters.NamedParameters) - { - string name = e.Key; - TypedValue typedval = e.Value; - int[] locs = GetNamedParameterLocs(name); - span += typedval.Type.GetColumnSpan(session.Factory) * locs.Length; - - for (int i = 0; i < locs.Length; i++) - { - ArrayHelper.SafeSetValue(paramTypeList, locs[i] + offset, typedval.Type); - } - } - } - return ConvertITypesToSqlTypes(paramTypeList, span, session); - } - - private static SqlType[] ConvertITypesToSqlTypes(IList<IType> nhTypes, int totalSpan, ISessionImplementor session) - { - SqlType[] result = new SqlType[totalSpan]; - - int index = 0; - foreach (IType type in nhTypes) - { - int span = type.SqlTypes(session.Factory).Length; - Array.Copy(type.SqlTypes(session.Factory), 0, result, index, span); - index += span; - } - - return result; - } } } Modified: trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2010-02-07 12:15:51 UTC (rev 4943) +++ trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2010-02-16 22:50:19 UTC (rev 4944) @@ -6,6 +6,7 @@ using NHibernate.Hql.Classic; using NHibernate.Impl; using NHibernate.SqlCommand; +using NHibernate.SqlTypes; using NHibernate.Transform; using NHibernate.Type; using NHibernate.Util; @@ -392,31 +393,162 @@ processedSQL = result.ToSqlString(); } - public int BindParameters(IDbCommand command, GetNamedParameterLocations getNamedParameterLocations, int start, - ISessionImplementor session) + private IList<Parameter> ResetParameterLocations(SqlString sqlString) { + IList<Parameter> sqlParameters = new List<Parameter>(); + + foreach (object sqlParameter in sqlString.Parts) + { + if (sqlParameter is Parameter) + { + Parameter parameter = (Parameter)sqlParameter; + parameter.ParameterPosition = null; + sqlParameters.Add(parameter); + } + } + + return sqlParameters; + } + + private void SetParameterLocation(IList<Parameter> sqlParameters, int parameterIndex, int sqlLocation, int span) + { + int i = 0; + while (i < span) + { + sqlParameters[sqlLocation + i].ParameterPosition = parameterIndex + i; + i++; + } + } + + private SqlType[] ConvertITypesToSqlTypes(List<IType> nhTypes, ISessionFactoryImplementor factory, int totalSpan) + { + SqlType[] result = new SqlType[totalSpan]; + + int index = 0; + foreach (IType type in nhTypes) + { + int span = type.SqlTypes(factory).Length; + Array.Copy(type.SqlTypes(factory), 0, result, index, span); + index += span; + } + + return result; + } + + public SqlType[] PrepareParameterTypes(SqlString sqlString, ISessionFactoryImplementor factory, GetNamedParameterLocations getNamedParameterLocations, int startParameterIndex, bool addLimit, bool addOffset) + { + List<IType> paramTypeList = new List<IType>(); + int parameterIndex = 0; + int totalSpan = 0; + + IList<Parameter> sqlParameters = ResetParameterLocations(sqlString); + + for (int index = 0; index < PositionalParameterTypes.Length; index++) + { + IType type = PositionalParameterTypes[index]; + ArrayHelper.SafeSetValue(paramTypeList, parameterIndex, type); + + int location = PositionalParameterLocations[index]; + location = FindAdjustedParameterLocation(location); + int span = type.GetColumnSpan(factory); + SetParameterLocation(sqlParameters, startParameterIndex + parameterIndex, location, span); + + totalSpan += span; + parameterIndex++; + } + + for (int index = 0; index < FilteredParameterTypes.Count; index++) + { + IType type = FilteredParameterTypes[index]; + ArrayHelper.SafeSetValue(paramTypeList, parameterIndex, type); + + int location = FilteredParameterLocations[index]; + int span = type.GetColumnSpan(factory); + SetParameterLocation(sqlParameters, startParameterIndex + parameterIndex, location, span); + + totalSpan += span; + parameterIndex++; + } + + if (NamedParameters != null && NamedParameters.Count > 0) + { + // convert the named parameters to an array of types + foreach (KeyValuePair<string, TypedValue> namedParameter in NamedParameters) + { + TypedValue typedval = namedParameter.Value; + ArrayHelper.SafeSetValue(paramTypeList, parameterIndex, typedval.Type); + + int span = typedval.Type.GetColumnSpan(factory); + string name = namedParameter.Key; + int[] locs = getNamedParameterLocations(name); + for (int i = 0; i < locs.Length; i++) + { + int location = locs[i]; + location = FindAdjustedParameterLocation(location); + + // can still clash with positional parameters + // could consider throwing an exception to locate problem (NH-1098) + while ((location < sqlParameters.Count) && (sqlParameters[location].ParameterPosition != null)) + location++; + + SetParameterLocation(sqlParameters, startParameterIndex + parameterIndex, location, span); + } + + totalSpan += span; + parameterIndex++; + } + } + + if (addLimit && factory.Dialect.SupportsVariableLimit) + { + if (factory.Dialect.BindLimitParametersFirst) + { + paramTypeList.Insert(0, NHibernateUtil.Int32); + if (addOffset) + { + paramTypeList.Insert(0, NHibernateUtil.Int32); + } + } + else + { + paramTypeList.Add(NHibernateUtil.Int32); + if (addOffset) + { + paramTypeList.Add(NHibernateUtil.Int32); + } + } + + totalSpan += addOffset ? 2 : 1; + } + + return ConvertITypesToSqlTypes(paramTypeList, factory, totalSpan); + } + + public int BindParameters(IDbCommand command, int start, ISessionImplementor session) + { + int location = 0; var values = new List<object>(); var types = new List<IType>(); var sources = new List<string>(); for (int i = 0; i < _positionalParameterLocations.Length; i++) { - int location = FindAdjustedParameterLocation(_positionalParameterLocations[i]); object value = _positionalParameterValues[i]; IType type = _positionalParameterTypes[i]; ArrayHelper.SafeSetValue(values, location, value); ArrayHelper.SafeSetValue(types, location, type); ArrayHelper.SafeSetValue(sources, location, "Positional" + i); + location++; } for (int i = 0; i < filteredParameterLocations.Count; i++) { - int location = filteredParameterLocations[i]; object value = filteredParameterValues[i]; IType type = filteredParameterTypes[i]; ArrayHelper.SafeSetValue(values, location, value); ArrayHelper.SafeSetValue(types, location, type); ArrayHelper.SafeSetValue(sources, location, "Filter" + i); + location++; } if ((_namedParameters != null) && (_namedParameters.Count > 0)) @@ -425,22 +557,10 @@ { string name = namedParameter.Key; TypedValue typedval = namedParameter.Value; - int[] locations = getNamedParameterLocations(name); - for (int i = 0; i < locations.Length; i++) - { - int location = FindAdjustedParameterLocation(locations[i]); - - // can still clash with positional parameters - // could consider throwing an exception to locate problem (NH-1098) - while ((location < types.Count) && (types[location] != null)) - { - location++; - } - - ArrayHelper.SafeSetValue(values, location, typedval.Value); - ArrayHelper.SafeSetValue(types, location, typedval.Type); - ArrayHelper.SafeSetValue(sources, location, "name" + i); - } + ArrayHelper.SafeSetValue(values, location, typedval.Value); + ArrayHelper.SafeSetValue(types, location, typedval.Type); + ArrayHelper.SafeSetValue(sources, location, "name_" + name); + location++; } } Modified: trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2010-02-07 12:15:51 UTC (rev 4943) +++ trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2010-02-16 22:50:19 UTC (rev 4944) @@ -180,7 +180,7 @@ translators.Add(translator); QueryParameters queryParameters = translator.GetQueryParameters(); parameters.Add(queryParameters); - SqlCommandInfo commandInfo = loader.GetQueryStringAndTypes(session, queryParameters); + SqlCommandInfo commandInfo = loader.GetQueryStringAndTypes(session, queryParameters, types.Count); sqlString = sqlString.Append(commandInfo.Text) .Append(session.Factory.ConnectionProvider.Driver.MultipleQueriesSeparator) .Append(Environment.NewLine); @@ -339,7 +339,7 @@ for (int i = 0; i < loaders.Count; i++) { QueryParameters parameter = parameters[i]; - colIndex += parameter.BindParameters(command, loaders[i].GetNamedParameterLocs, colIndex, session); + colIndex += parameter.BindParameters(command, colIndex, session); } return colIndex; } Modified: trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2010-02-07 12:15:51 UTC (rev 4943) +++ trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2010-02-16 22:50:19 UTC (rev 4944) @@ -616,7 +616,7 @@ translators.Add(translator); parameters.Add(queryParameters); queryParameters = GetFilteredQueryParameters(queryParameters, translator); - SqlCommandInfo commandInfo = translator.Loader.GetQueryStringAndTypes(session, queryParameters); + SqlCommandInfo commandInfo = translator.Loader.GetQueryStringAndTypes(session, queryParameters, types.Count); sqlString = sqlString.Append(commandInfo.Text).Append(session.Factory.ConnectionProvider.Driver.MultipleQueriesSeparator).Append(Environment.NewLine); types.AddRange(commandInfo.ParameterTypes); } @@ -668,7 +668,7 @@ { IQueryTranslator translator = Translators[i]; QueryParameters parameter = Parameters[i]; - colIndex += parameter.BindParameters(command, translator.Loader.GetNamedParameterLocs, colIndex, session); + colIndex += parameter.BindParameters(command, colIndex, session); } return colIndex; } Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionParameterVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionParameterVisitor.cs 2010-02-07 12:15:51 UTC (rev 4943) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionParameterVisitor.cs 2010-02-16 22:50:19 UTC (rev 4944) @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using Remotion.Data.Linq.Parsing; @@ -23,12 +24,17 @@ protected override Expression VisitConstantExpression(ConstantExpression expression) { - if (!typeof(IQueryable).IsAssignableFrom(expression.Type)) + if (!typeof(IQueryable).IsAssignableFrom(expression.Type) && !IsNullObject(expression)) { _parameters.Add(expression, new NamedParameter("p" + (_parameters.Count + 1), expression.Value, NHibernateUtil.GuessType(expression.Type))); } return base.VisitConstantExpression(expression); } + + private bool IsNullObject(ConstantExpression expression) + { + return expression.Type == typeof(Object) && expression.Value == null; + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2010-02-07 12:15:51 UTC (rev 4943) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2010-02-16 22:50:19 UTC (rev 4944) @@ -1106,6 +1106,8 @@ bool useOffset = hasFirstRow && useLimit && dialect.SupportsLimitOffset; // TODO NH bool callable = queryParameters.Callable; + SqlType[] parameterTypes = queryParameters.PrepareParameterTypes(sqlString, Factory, GetNamedParameterLocs, 0, useLimit, useOffset); + if (useLimit) { sqlString = @@ -1116,8 +1118,7 @@ // TODO NH: Callable for SP -> PrepareCallableQueryCommand IDbCommand command = - session.Batcher.PrepareQueryCommand(CommandType.Text, sqlString, - GetParameterTypes(queryParameters, useLimit, useOffset)); + session.Batcher.PrepareQueryCommand(CommandType.Text, sqlString, parameterTypes); try { @@ -1263,7 +1264,7 @@ // NH Different behavior: // The responsibility of parameter binding was entirely moved to QueryParameters // to deal with positionslParameter+NamedParameter+ParameterOfFilters - return queryParameters.BindParameters(statement, GetNamedParameterLocs, 0, session); + return queryParameters.BindParameters(statement, 0, session); } public virtual int[] GetNamedParameterLocs(string name) @@ -1683,7 +1684,7 @@ #region NHibernate specific - public virtual SqlCommandInfo GetQueryStringAndTypes(ISessionImplementor session, QueryParameters parameters) + public virtual SqlCommandInfo GetQueryStringAndTypes(ISessionImplementor session, QueryParameters parameters, int startParameterIndex) { SqlString sqlString = ProcessFilters(parameters, session); Dialect.Dialect dialect = session.Factory.Dialect; @@ -1693,6 +1694,8 @@ bool hasFirstRow = GetFirstRow(selection) > 0; bool useOffset = hasFirstRow && useLimit && dialect.SupportsLimitOffset; + SqlType[] sqlTypes = parameters.PrepareParameterTypes(sqlString, Factory, GetNamedParameterLocs, startParameterIndex, useLimit, useOffset); + if (useLimit) { sqlString = @@ -1700,97 +1703,9 @@ } sqlString = PreprocessSQL(sqlString, parameters, dialect); - return new SqlCommandInfo(sqlString, GetParameterTypes(parameters, useLimit, useOffset)); + return new SqlCommandInfo(sqlString, sqlTypes); } - protected SqlType[] ConvertITypesToSqlTypes(List<IType> nhTypes, int totalSpan) - { - SqlType[] result = new SqlType[totalSpan]; - - int index = 0; - foreach (IType type in nhTypes) - { - int span = type.SqlTypes(Factory).Length; - Array.Copy(type.SqlTypes(Factory), 0, result, index, span); - index += span; - } - - return result; - } - - /// <returns><see cref="IList" /> of <see cref="IType" /></returns> - protected SqlType[] GetParameterTypes(QueryParameters parameters, bool addLimit, bool addOffset) - { - List<IType> paramTypeList = new List<IType>(); - int span = 0; - - for (int index = 0; index < parameters.PositionalParameterTypes.Length; index++) - { - int location = parameters.PositionalParameterLocations[index]; - location = parameters.FindAdjustedParameterLocation(location); - IType type = parameters.PositionalParameterTypes[index]; - ArrayHelper.SafeSetValue(paramTypeList, location, type); - span += type.GetColumnSpan(Factory); - } - - for (int index = 0; index < parameters.FilteredParameterTypes.Count; index++) - { - int location = parameters.FilteredParameterLocations[index]; - IType type = parameters.FilteredParameterTypes[index]; - ArrayHelper.SafeSetValue(paramTypeList, location, type); - span += type.GetColumnSpan(Factory); - } - - if (parameters.NamedParameters != null && parameters.NamedParameters.Count > 0) - { - // convert the named parameters to an array of types - foreach (KeyValuePair<string, TypedValue> namedParameter in parameters.NamedParameters) - { - string name = namedParameter.Key; - TypedValue typedval = namedParameter.Value; - int[] locs = GetNamedParameterLocs(name); - span += typedval.Type.GetColumnSpan(Factory) * locs.Length; - - for (int i = 0; i < locs.Length; i++) - { - int location = locs[i]; - location = parameters.FindAdjustedParameterLocation(location); - - // can still clash with positional parameters - // could consider throwing an exception to locate problem (NH-1098) - while ((location < paramTypeList.Count) && (paramTypeList[location] != null)) - location++; - - ArrayHelper.SafeSetValue(paramTypeList, location, typedval.Type); - } - } - } - - if (addLimit && Factory.Dialect.SupportsVariableLimit) - { - if (Factory.Dialect.BindLimitParametersFirst) - { - paramTypeList.Insert(0, NHibernateUtil.Int32); - if (addOffset) - { - paramTypeList.Insert(0, NHibernateUtil.Int32); - } - } - else - { - paramTypeList.Add(NHibernateUtil.Int32); - if (addOffset) - { - paramTypeList.Add(NHibernateUtil.Int32); - } - } - - span += addOffset ? 2 : 1; - } - - return ConvertITypesToSqlTypes(paramTypeList, span); - } - #endregion } } Modified: trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs 2010-02-07 12:15:51 UTC (rev 4943) +++ trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs 2010-02-16 22:50:19 UTC (rev 4944) @@ -10,16 +10,13 @@ [Serializable] public class Parameter { - /// <summary> + /// <summary> /// We need to know what the position of the parameter was in a query /// before we rearranged the query. - /// This is used only by dialects that rearrange the query, unfortunately, - /// the MS SQL 2005 dialect have to re shuffle the query (and ruin positional parameter - /// support) because the SQL 2005 and 2008 SQL dialects have a completely broken - /// support for paging, which is just a tad less important than SELECT. - /// See NH-1528 - /// </summary> - public int? OriginalPositionInQuery; + /// This is the ADO parameter position that this SqlString parameter is + /// bound to. The SqlString can be safely rearranged once this is set. + /// </summary> + public int? ParameterPosition; /// <summary> /// Used as a placeholder when parsing HQL or SQL queries. Modified: trunk/nhibernate/src/NHibernate.Test/Linq/RegresstionTests.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/RegresstionTests.cs 2010-02-07 12:15:51 UTC (rev 4943) +++ trunk/nhibernate/src/NHibernate.Test/Linq/RegresstionTests.cs 2010-02-16 22:50:19 UTC (rev 4944) @@ -1,5 +1,6 @@ using System.Linq; using NUnit.Framework; +using NHibernate.Test.Linq.Entities; namespace NHibernate.Test.Linq { @@ -10,7 +11,7 @@ /// http://aspzone.com/tech/nhibernate-linq-troubles/ /// </summary> [Test] - public void HierarchicalQueries() + public void HierarchicalQueries_InlineConstant() { var children = from s in db.Role where s.ParentRole != null @@ -24,5 +25,32 @@ Assert.AreEqual(2, roots.Count()); } + + [Test] + public void HierarchicalQueries_Variable() + { + Role testRole = null; + var children = from s in db.Role + where s.ParentRole != testRole + select s; + + Assert.AreEqual(0, children.Count()); + + var roots = from s in db.Role + where s.ParentRole == testRole + select s; + + Assert.AreEqual(2, roots.Count()); + } + [Test] + public void CanUseNullConstantAndRestriction() + { + var roots = from s in db.Role + where s.ParentRole == null + && s.Name == "Admin" + select s; + + Assert.AreEqual(1, roots.Count()); + } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1981/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1981/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1981/Fixture.cs 2010-02-16 22:50:19 UTC (rev 4944) @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using NHibernate.Cfg; +using NHibernate.Tool.hbm2ddl; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1981 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void CanGroupWithParameter() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Save(new Article() { Longitude = 90 }); + s.Save(new Article() { Longitude = 90 }); + s.Save(new Article() { Longitude = 120 }); + + IList<double> quotients = + s.CreateQuery( + @"select (Longitude / :divisor) + from Article + group by (Longitude / :divisor)") + .SetDouble("divisor", 30) + .List<double>(); + + Assert.That(quotients.Count, Is.EqualTo(2)); + Assert.That(quotients[0], Is.EqualTo(3)); + Assert.That(quotients[1], Is.EqualTo(4)); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1981/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1981/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1981/Mappings.hbm.xml 2010-02-16 22:50:19 UTC (rev 4944) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1981" + assembly="NHibernate.Test"> + + <class name="Article"> + <id name="Id"> + <generator class="hilo" /> + </id> + <property name="Longitude" /> + </class> +</hibernate-mapping> + + Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1981/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1981/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1981/Model.cs 2010-02-16 22:50:19 UTC (rev 4944) @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1981 +{ + public class Article + { + public virtual int Id { get; set; } + public virtual double Longitude { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-02-07 12:15:51 UTC (rev 4943) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-02-16 22:50:19 UTC (rev 4944) @@ -663,6 +663,8 @@ <Compile Include="NHSpecificTest\NH1978\AliasTest.cs" /> <Compile Include="NHSpecificTest\NH1978\Employee.cs" /> <Compile Include="NHSpecificTest\NH1978\_401k.cs" /> + <Compile Include="NHSpecificTest\NH1981\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1981\Model.cs" /> <Compile Include="NHSpecificTest\NH1989\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1989\Model.cs" /> <Compile Include="NHSpecificTest\NH2009\Fixture.cs" /> @@ -2121,6 +2123,7 @@ <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1981\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2074\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2077\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2020\Mappings.hbm.xml" /> Modified: trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlStringFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlStringFixture.cs 2010-02-07 12:15:51 UTC (rev 4943) +++ trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlStringFixture.cs 2010-02-16 22:50:19 UTC (rev 4944) @@ -375,8 +375,8 @@ Assert.AreEqual(parameterString1, parameterString2); Assert.AreNotSame(parameterString1, parameterString2); - parameters1[0].OriginalPositionInQuery = 231; - Assert.IsNull(parameters2[0].OriginalPositionInQuery); + parameters1[0].ParameterPosition = 231; + Assert.IsNull(parameters2[0].ParameterPosition); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Get V. P. on www.11-55.cn <mit...@an...> - 2010-02-14 18:00:15
|
sabba t spumo ni berri es volks lied venal ity puppe tizes leath erize s patri ots ratio nalis es bylot botar go hewn unvis ited commi nute anxio usly gribb le doodl e affab ly deans hip chase rs worml ike integ ratio ns jaspe rs magni fiers gribb le punct ure parqu etry berri es machi nates recop ied avala nched styli form obedi ences anale mmas conce iving oxyge nisab le tendr ilous assiu t kitti wake pertl y enarb ours groun dsill jaspe rs house fathe r |
From: <ric...@us...> - 2010-02-07 12:39:09
|
Revision: 4943 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4943&view=rev Author: ricbrown Date: 2010-02-07 12:15:51 +0000 (Sun, 07 Feb 2010) Log Message: ----------- Fix NH-2101 (Missing IsNotIn for WhereRestrictionOn) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverRestrictionBuilder.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/RestrictionsFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverRestrictionBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverRestrictionBuilder.cs 2010-02-01 20:48:56 UTC (rev 4942) +++ trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverRestrictionBuilder.cs 2010-02-07 12:15:51 UTC (rev 4943) @@ -16,6 +16,15 @@ public QueryOverRestrictionBuilder(QueryOver<TRoot,TSubType> root, string propertyName) : base(root, propertyName) { } + public QueryOverRestrictionBuilder<TRoot,TSubType> Not + { + get + { + isNot = !isNot; + return this; + } + } + } public class IQueryOverRestrictionBuilder<TRoot,TSubType> : QueryOverRestrictionBuilderBase<IQueryOver<TRoot,TSubType>, TRoot, TSubType> @@ -24,6 +33,15 @@ public IQueryOverRestrictionBuilder(IQueryOver<TRoot,TSubType> root, string propertyName) : base(root, propertyName) { } + public IQueryOverRestrictionBuilder<TRoot,TSubType> Not + { + get + { + isNot = !isNot; + return this; + } + } + } public class QueryOverRestrictionBuilderBase<TReturn,TRoot,TSubType> @@ -33,23 +51,34 @@ { private TReturn root; private string propertyName; + private bool isNot; private object lo; - public LambdaBetweenBuilder(TReturn root, string propertyName, object lo) + public LambdaBetweenBuilder(TReturn root, string propertyName, bool isNot, object lo) { this.root = root; this.propertyName = propertyName; + this.isNot = isNot; this.lo = lo; } + private TReturn Add(ICriterion criterion) + { + if (isNot) + criterion = Restrictions.Not(criterion); + + return (TReturn)root.And(criterion); + } + public TReturn And(object hi) { - return (TReturn)root.And(Restrictions.Between(propertyName, lo, hi)); + return Add(Restrictions.Between(propertyName, lo, hi)); } } private TReturn root; private string propertyName; + protected bool isNot; /// <summary> /// Constructed with property name @@ -60,12 +89,20 @@ this.propertyName = propertyName; } + private TReturn Add(ICriterion criterion) + { + if (isNot) + criterion = Restrictions.Not(criterion); + + return (TReturn)root.And(criterion); + } + /// <summary> /// Apply a "between" constraint to the named property /// </summary> public LambdaBetweenBuilder IsBetween(object lo) { - return new LambdaBetweenBuilder(root, propertyName, lo); + return new LambdaBetweenBuilder(root, propertyName, isNot, lo); } /// <summary> @@ -73,7 +110,7 @@ /// </summary> public TReturn IsIn(ICollection values) { - return (TReturn)root.And(Restrictions.In(propertyName, values)); + return Add(Restrictions.In(propertyName, values)); } /// <summary> @@ -81,7 +118,7 @@ /// </summary> public TReturn IsIn(object[] values) { - return (TReturn)root.And(Restrictions.In(propertyName, values)); + return Add(Restrictions.In(propertyName, values)); } /// <summary> @@ -89,7 +126,7 @@ /// </summary> public TReturn IsInG<T>(ICollection<T> values) { - return (TReturn)root.And(Restrictions.InG(propertyName, values)); + return Add(Restrictions.InG(propertyName, values)); } /// <summary> @@ -97,7 +134,7 @@ /// </summary> public TReturn IsInsensitiveLike(object value) { - return (TReturn)root.And(Restrictions.InsensitiveLike(propertyName, value)); + return Add(Restrictions.InsensitiveLike(propertyName, value)); } /// <summary> @@ -105,7 +142,7 @@ /// </summary> public TReturn IsInsensitiveLike(string value, MatchMode matchMode) { - return (TReturn)root.And(Restrictions.InsensitiveLike(propertyName, value, matchMode)); + return Add(Restrictions.InsensitiveLike(propertyName, value, matchMode)); } /// <summary> @@ -113,7 +150,7 @@ /// </summary> public TReturn IsEmpty { - get { return (TReturn)root.And(Restrictions.IsEmpty(propertyName)); } + get { return Add(Restrictions.IsEmpty(propertyName)); } } /// <summary> @@ -121,7 +158,7 @@ /// </summary> public TReturn IsNotEmpty { - get { return (TReturn)root.And(Restrictions.IsNotEmpty(propertyName)); } + get { return Add(Restrictions.IsNotEmpty(propertyName)); } } /// <summary> @@ -129,7 +166,7 @@ /// </summary> public TReturn IsNull { - get { return (TReturn)root.And(Restrictions.IsNull(propertyName)); } + get { return Add(Restrictions.IsNull(propertyName)); } } /// <summary> @@ -137,7 +174,7 @@ /// </summary> public TReturn IsNotNull { - get { return (TReturn)root.And(Restrictions.IsNotNull(propertyName)); } + get { return Add(Restrictions.IsNotNull(propertyName)); } } /// <summary> @@ -145,7 +182,7 @@ /// </summary> public TReturn IsLike(object value) { - return (TReturn)root.And(Restrictions.Like(propertyName, value)); + return Add(Restrictions.Like(propertyName, value)); } /// <summary> @@ -153,7 +190,7 @@ /// </summary> public TReturn IsLike(string value, MatchMode matchMode) { - return (TReturn)root.And(Restrictions.Like(propertyName, value, matchMode)); + return Add(Restrictions.Like(propertyName, value, matchMode)); } /// <summary> @@ -161,7 +198,7 @@ /// </summary> public TReturn IsLike(string value, MatchMode matchMode, char? escapeChar) { - return (TReturn)root.And(Restrictions.Like(propertyName, value, matchMode, escapeChar)); + return Add(Restrictions.Like(propertyName, value, matchMode, escapeChar)); } } Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/RestrictionsFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/RestrictionsFixture.cs 2010-02-01 20:48:56 UTC (rev 4942) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/RestrictionsFixture.cs 2010-02-07 12:15:51 UTC (rev 4943) @@ -112,6 +112,7 @@ CreateTestCriteria(typeof(Person), "personAlias") .Add(Restrictions.Between("Age", 18, 65)) .Add(Restrictions.Between("personAlias.Age", 18, 65)) + .Add(Restrictions.Not(Restrictions.Between("Age", 18, 65))) .Add(Restrictions.In("Name", new string[] { "name1", "name2", "name3" })) .Add(Restrictions.In("personAlias.Name", new ArrayList() { "name1", "name2", "name3" })) .Add(Restrictions.InG<int>("Age", new int[] { 1, 2, 3 })) @@ -123,13 +124,15 @@ .Add(Restrictions.IsNull("Name")) .Add(Restrictions.Like("Name", "%test%")) .Add(Restrictions.Like("Name", "test", MatchMode.Anywhere)) - .Add(Restrictions.Like("Name", "test", MatchMode.Anywhere, '?')); + .Add(Restrictions.Like("Name", "test", MatchMode.Anywhere, '?')) + .Add(Restrictions.Not(Restrictions.Like("Name", "%test%"))); Person personAlias = null; var actual = CreateTestQueryOver<Person>(() => personAlias) .WhereRestrictionOn(p => p.Age).IsBetween(18).And(65) .WhereRestrictionOn(() => personAlias.Age).IsBetween(18).And(65) + .WhereRestrictionOn(p => p.Age).Not.IsBetween(18).And(65) .AndRestrictionOn(p => p.Name).IsIn(new string[] { "name1", "name2", "name3" }) .AndRestrictionOn(() => personAlias.Name).IsIn(new ArrayList() { "name1", "name2", "name3" }) .AndRestrictionOn(p => p.Age).IsInG<int>(new int[] { 1, 2, 3 }) @@ -141,7 +144,8 @@ .AndRestrictionOn(p => p.Name).IsNull .AndRestrictionOn(p => p.Name).IsLike("%test%") .AndRestrictionOn(p => p.Name).IsLike("test", MatchMode.Anywhere) - .AndRestrictionOn(p => p.Name).IsLike("test", MatchMode.Anywhere, '?'); + .AndRestrictionOn(p => p.Name).IsLike("test", MatchMode.Anywhere, '?') + .AndRestrictionOn(p => p.Name).Not.IsLike("%test%"); AssertCriteriaAreEqual(expected, actual); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2010-02-01 21:27:38
|
Revision: 4942 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4942&view=rev Author: ayenderahien Date: 2010-02-01 20:48:56 +0000 (Mon, 01 Feb 2010) Log Message: ----------- Porting the fix to HHH-2795 from Hibernate Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/Loading/CollectionLoadContext.cs trunk/nhibernate/src/NHibernate/Engine/Loading/LoadContexts.cs Modified: trunk/nhibernate/src/NHibernate/Engine/Loading/CollectionLoadContext.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Loading/CollectionLoadContext.cs 2010-02-01 12:06:34 UTC (rev 4941) +++ trunk/nhibernate/src/NHibernate/Engine/Loading/CollectionLoadContext.cs 2010-02-01 20:48:56 UTC (rev 4942) @@ -147,7 +147,7 @@ /// <param name="persister">The persister for which to complete loading. </param> public void EndLoadingCollections(ICollectionPersister persister) { - if (!loadContexts.HasLoadingCollectionEntries || (localLoadingCollectionKeys.Count == 0)) + if (!loadContexts.HasLoadingCollectionEntries && (localLoadingCollectionKeys.Count == 0)) { return; } Modified: trunk/nhibernate/src/NHibernate/Engine/Loading/LoadContexts.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Loading/LoadContexts.cs 2010-02-01 12:06:34 UTC (rev 4941) +++ trunk/nhibernate/src/NHibernate/Engine/Loading/LoadContexts.cs 2010-02-01 20:48:56 UTC (rev 4942) @@ -102,9 +102,19 @@ /// <returns> True if we currently hold state pertaining to loading collections; false otherwise. </returns> public bool HasLoadingCollectionEntries { - get { return (xrefLoadingCollectionEntries != null && !(xrefLoadingCollectionEntries.Count == 0)); } + get { return (collectionLoadContexts != null && collectionLoadContexts.Count != 0); } } + ///<summary> + /// Do we currently have any registered internal entries corresponding to loading + /// collections? + /// True if we currently hold state pertaining to a registered loading collections; false otherwise. + /// </summary> + public bool HasRegisteredLoadingCollectionEntries + { + get { return (xrefLoadingCollectionEntries != null && xrefLoadingCollectionEntries.Count != 0); } + } + /// <summary> /// Get the {@link CollectionLoadContext} associated with the given /// {@link ResultSet}, creating one if needed. @@ -200,7 +210,7 @@ /// </remarks> internal void UnregisterLoadingCollectionXRef(CollectionKey key) { - if (!HasLoadingCollectionEntries) + if (!HasRegisteredLoadingCollectionEntries) { return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2010-02-01 12:06:41
|
Revision: 4941 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4941&view=rev Author: ayenderahien Date: 2010-02-01 12:06:34 +0000 (Mon, 01 Feb 2010) Log Message: ----------- Upgrading to Castle Dynamic Proxy 2.2 Modified Paths: -------------- trunk/nhibernate/lib/net/3.5/Castle.Core.dll trunk/nhibernate/lib/net/3.5/Castle.Core.xml trunk/nhibernate/lib/net/3.5/Castle.DynamicProxy2.dll trunk/nhibernate/lib/net/3.5/Castle.DynamicProxy2.xml Modified: trunk/nhibernate/lib/net/3.5/Castle.Core.dll =================================================================== (Binary files differ) Modified: trunk/nhibernate/lib/net/3.5/Castle.Core.xml =================================================================== --- trunk/nhibernate/lib/net/3.5/Castle.Core.xml 2010-01-27 15:58:40 UTC (rev 4940) +++ trunk/nhibernate/lib/net/3.5/Castle.Core.xml 2010-02-01 12:06:34 UTC (rev 4941) @@ -220,52 +220,189 @@ </summary> <value>The type of the lifestyle handler.</value> </member> + <member name="T:Castle.DynamicProxy.IAttributeDisassembler"> + <summary> + Provides functionality for disassembling instances of attributes to CustomAttributeBuilder form, during the process of emiting new types by Dynamic Proxy. + </summary> + </member> + <member name="M:Castle.DynamicProxy.IAttributeDisassembler.Disassemble(System.Attribute)"> + <summary> + Disassembles given attribute instance back to corresponding CustomAttributeBuilder. + </summary> + <param name="attribute">An instance of attribute to disassemble</param> + <returns><see cref="T:System.Reflection.Emit.CustomAttributeBuilder"/> corresponding 1 to 1 to given attribute instance, or null reference.</returns> + <remarks> + Implementers should return <see cref="T:System.Reflection.Emit.CustomAttributeBuilder"/> that corresponds to given attribute instance 1 to 1, + that is after calling specified constructor with specified arguments, and setting specified properties and fields with values specified + we should be able to get an attribute instance identical to the one passed in <paramref name="attribute"/>. Implementer can return null + if it wishes to opt out of replicating the attribute. Notice however, that for some cases, like attributes passed explicitly by the user + it is illegal to return null, and doing so will result in exception. + </remarks> + </member> + <member name="T:Castle.Core.Interceptor.IChangeProxyTarget"> + <summary> + Exposes means to change target objects of proxies and invocations + </summary> + </member> + <member name="M:Castle.Core.Interceptor.IChangeProxyTarget.ChangeInvocationTarget(System.Object)"> + <summary> + Changes the target object (<see cref="P:Castle.Core.Interceptor.IInvocation.InvocationTarget"/>) of current <see cref="T:Castle.Core.Interceptor.IInvocation"/>. + </summary> + <param name="target">The new value of target of invocation.</param> + <remarks> + Although the method takes <see cref="T:System.Object"/> the actual instance must be of type assignable to <see cref="P:Castle.Core.Interceptor.IInvocation.TargetType"/>, otherwise an <see cref="T:System.InvalidCastException"/> will be thrown. + Also while it's technically legal to pass null reference (Nothing in Visual Basic) as <paramref name="target"/>, for obvious reasons Dynamic Proxy will not be able to call the intercepted method on such target. + In this case last interceptor in the pipeline mustn't call <see cref="M:Castle.Core.Interceptor.IInvocation.Proceed"/> or a <see cref="T:System.NotImplementedException"/> will be throws. + Also while it's technically legal to pass proxy itself as <paramref name="target"/>, this would create stack overflow. + In this case last interceptor in the pipeline mustn't call <see cref="M:Castle.Core.Interceptor.IInvocation.Proceed"/> or a <see cref="T:System.InvalidOperationException"/> will be throws. + </remarks> + <exception cref="T:System.InvalidCastException">Thrown when <paramref name="target"/> is not assignable to the proxied type.</exception> + </member> + <member name="M:Castle.Core.Interceptor.IChangeProxyTarget.ChangeProxyTarget(System.Object)"> + <summary> + Permanently changes the target object of the proxy. This does not affect target of the current invocation. + </summary> + <param name="target">The new value of target of the proxy.</param> + <remarks> + Although the method takes <see cref="T:System.Object"/> the actual instance must be of type assignable to proxy's target type, otherwise an <see cref="T:System.InvalidCastException"/> will be thrown. + Also while it's technically legal to pass null reference (Nothing in Visual Basic) as <paramref name="target"/>, for obvious reasons Dynamic Proxy will not be able to call the intercepted method on such target. + In this case last interceptor in the pipeline mustn't call <see cref="M:Castle.Core.Interceptor.IInvocation.Proceed"/> or a <see cref="T:System.NotImplementedException"/> will be throws. + Also while it's technically legal to pass proxy itself as <paramref name="target"/>, this would create stack overflow. + In this case last interceptor in the pipeline mustn't call <see cref="M:Castle.Core.Interceptor.IInvocation.Proceed"/> or a <see cref="T:System.InvalidOperationException"/> will be throws. + </remarks> + <exception cref="T:System.InvalidCastException">Thrown when <paramref name="target"/> is not assignable to the proxied type.</exception> + </member> <member name="T:Castle.Core.Interceptor.IInterceptor"> <summary> New interface that is going to be used by DynamicProxy 2 </summary> </member> + <member name="T:Castle.Core.Interceptor.IInterceptorSelector"> + <summary> + Provides an extension point that allows proxies to choose specific interceptors on + a per method basis. + </summary> + </member> + <member name="M:Castle.Core.Interceptor.IInterceptorSelector.SelectInterceptors(System.Type,System.Reflection.MethodInfo,Castle.Core.Interceptor.IInterceptor[])"> + <summary> + Selects the interceptors that should intercept calls to the given <paramref name="method"/>. + </summary> + <param name="type">The type declaring the method to intercept.</param> + <param name="method">The method that will be intercepted.</param> + <param name="interceptors">All interceptors registered with the proxy.</param> + <returns>An array of interceptors to invoke upon calling the <paramref name="method"/>.</returns> + <remarks> + This method is called only once per proxy instance, upon the first call to the + <paramref name="method"/>. Either an empty array or null are valid return values to indicate + that no interceptor should intercept calls to the method. Although it is not advised, it is + legal to return other <see cref="T:Castle.Core.Interceptor.IInterceptor"/> implementations than these provided in + <paramref name="interceptors"/>. + </remarks> + </member> <member name="T:Castle.Core.Interceptor.IInvocation"> <summary> - New interface that is going to be used by DynamicProxy 2 + Encapsulates an invocation of a proxied method. </summary> </member> + <member name="M:Castle.Core.Interceptor.IInvocation.SetArgumentValue(System.Int32,System.Object)"> + <summary> + Overrides the value of an argument at the given <paramref name="index"/> with the + new <paramref name="value"/> provided. + </summary> + <remarks> + This method accepts an <see cref="T:System.Object"/>, however the value provided must be compatible + with the type of the argument defined on the method, otherwise an exception will be thrown. + </remarks> + <param name="index">The index of the argument to override.</param> + <param name="value">The new value for the argument.</param> + </member> + <member name="M:Castle.Core.Interceptor.IInvocation.GetArgumentValue(System.Int32)"> + <summary> + Gets the value of the argument at the specified <paramref name="index"/>. + </summary> + <param name="index">The index.</param> + <returns>The value of the argument at the specified <paramref name="index"/>.</returns> + </member> <member name="M:Castle.Core.Interceptor.IInvocation.GetConcreteMethod"> <summary> - Returns the concrete instantiation of <see cref="P:Castle.Core.Interceptor.IInvocation.Method"/>, with any generic parameters bound to real types. + Returns the concrete instantiation of the <see cref="P:Castle.Core.Interceptor.IInvocation.Method"/>, with any generic + parameters bound to real types. </summary> - <returns>The concrete instantiation of <see cref="P:Castle.Core.Interceptor.IInvocation.Method"/>, or <see cref="P:Castle.Core.Interceptor.IInvocation.Method"/> if not a generic method.</returns> + <returns> + The concrete instantiation of the <see cref="P:Castle.Core.Interceptor.IInvocation.Method"/>, or the <see cref="P:Castle.Core.Interceptor.IInvocation.Method"/> if + not a generic method. + </returns> <remarks>Can be slower than calling <see cref="P:Castle.Core.Interceptor.IInvocation.Method"/>.</remarks> </member> <member name="M:Castle.Core.Interceptor.IInvocation.GetConcreteMethodInvocationTarget"> <summary> - Returns the concrete instantiation of <see cref="P:Castle.Core.Interceptor.IInvocation.MethodInvocationTarget"/>, with any generic parameters bound to real types. + Returns the concrete instantiation of <see cref="P:Castle.Core.Interceptor.IInvocation.MethodInvocationTarget"/>, with any + generic parameters bound to real types. </summary> - <returns>The concrete instantiation of <see cref="P:Castle.Core.Interceptor.IInvocation.MethodInvocationTarget"/>, or <see cref="P:Castle.Core.Interceptor.IInvocation.MethodInvocationTarget"/> if not a generic method.</returns> + <returns>The concrete instantiation of <see cref="P:Castle.Core.Interceptor.IInvocation.MethodInvocationTarget"/>, or + <see cref="P:Castle.Core.Interceptor.IInvocation.MethodInvocationTarget"/> if not a generic method.</returns> <remarks>Can be slower than calling <see cref="P:Castle.Core.Interceptor.IInvocation.MethodInvocationTarget"/>.</remarks> </member> <member name="M:Castle.Core.Interceptor.IInvocation.Proceed"> <summary> - + Proceeds the call to the next interceptor in line, and ultimately to the target method. </summary> - <returns></returns> + <remarks> + Since interface proxies without a target don't have the target implementation to proceed to, + it is important, that the last interceptor does not call this method, otherwise a + <see cref="T:System.NotImplementedException"/> will be thrown. + </remarks> </member> + <member name="P:Castle.Core.Interceptor.IInvocation.Proxy"> + <summary> + Gets the proxy object on which the intercepted method is invoked. + </summary> + <value>Proxy object on which the intercepted method is invoked.</value> + </member> + <member name="P:Castle.Core.Interceptor.IInvocation.InvocationTarget"> + <summary> + Gets the object on which the invocation is performed. This is different from proxy object + because most of the time this will be the proxy target object. + </summary> + <seealso cref="T:Castle.Core.Interceptor.IChangeProxyTarget"/> + <value>The invocation target.</value> + </member> + <member name="P:Castle.Core.Interceptor.IInvocation.TargetType"> + <summary> + Gets the type of the target object for the intercepted method. + </summary> + <value>The type of the target object.</value> + </member> + <member name="P:Castle.Core.Interceptor.IInvocation.Arguments"> + <summary> + Gets the arguments that the <see cref="P:Castle.Core.Interceptor.IInvocation.Method"/> has been invoked with. + </summary> + <value>The arguments the method was invoked with.</value> + </member> <member name="P:Castle.Core.Interceptor.IInvocation.GenericArguments"> <summary> - The generic arguments of the method, or null if not a generic method. + Gets the generic arguments of the method. </summary> + <value>The generic arguments, or null if not a generic method.</value> </member> <member name="P:Castle.Core.Interceptor.IInvocation.Method"> <summary> - + Gets the <see cref="T:System.Reflection.MethodInfo"/> representing the method being invoked. </summary> + <value>The <see cref="T:System.Reflection.MethodInfo"/> representing the method being invoked.</value> </member> <member name="P:Castle.Core.Interceptor.IInvocation.MethodInvocationTarget"> <summary> - For interface proxies, this will point to the - <see cref="T:System.Reflection.MethodInfo"/> on the target class + For interface proxies, this will point to the <see cref="T:System.Reflection.MethodInfo"/> on the target class. </summary> + <value>The method invocation target.</value> </member> + <member name="P:Castle.Core.Interceptor.IInvocation.ReturnValue"> + <summary> + Gets or sets the return value of the method. + </summary> + <value>The return value of the method.</value> + </member> <member name="T:Castle.Core.Interceptor.IOnBehalfAware"> <summary> Interceptors might implement this to receive the @@ -348,6 +485,12 @@ If the index is invalid. </exception> </member> + <member name="M:Castle.Core.Internal.Lock.Create"> + <summary> + Creates a new lock. + </summary> + <returns></returns> + </member> <member name="T:Castle.Core.IInitializable"> <summary> Lifecycle interface. If implemented by a component, @@ -2077,14 +2220,14 @@ instance in a pool instead of always creating them. </summary> </member> - <member name="F:Castle.Core.LifestyleType.Custom"> + <member name="F:Castle.Core.LifestyleType.PerWebRequest"> <summary> - Any other logic to create/release components. + PerWebRequest components are created once per Http Request </summary> </member> - <member name="F:Castle.Core.LifestyleType.PerWebRequest"> + <member name="F:Castle.Core.LifestyleType.Custom"> <summary> - PerWebRequest components are created once per Http Request + Any other logic to create/release components. </summary> </member> <member name="T:Castle.Core.PropertiesInspectionBehavior"> @@ -2716,11 +2859,6 @@ Collection of <see cref="T:Castle.Core.ParameterModel"/> </summary> </member> - <member name="M:Castle.Core.ParameterModelCollection.#ctor"> - <summary> - Initializes a new instance of the <see cref="T:Castle.Core.ParameterModelCollection"/> class. - </summary> - </member> <member name="M:Castle.Core.ParameterModelCollection.Add(System.String,System.String)"> <summary> Adds the specified name. @@ -3001,6 +3139,126 @@ Enable access to files on network shares </summary> </member> + <member name="T:Castle.Core.Smtp.DefaultSmtpSender"> + <summary> + Default <see cref="T:Castle.Core.Smtp.IEmailSender"/> implementation. + </summary> + </member> + <member name="T:Castle.Core.Smtp.IEmailSender"> + <summary> + Email sender abstraction. + </summary> + </member> + <member name="M:Castle.Core.Smtp.IEmailSender.Send(System.String,System.String,System.String,System.String)"> + <summary> + Sends a mail message. + </summary> + <param name="from">From field</param> + <param name="to">To field</param> + <param name="subject">E-mail's subject</param> + <param name="messageText">message's body</param> + </member> + <member name="M:Castle.Core.Smtp.IEmailSender.Send(System.Net.Mail.MailMessage)"> + <summary> + Sends a <see cref="T:System.Net.Mail.MailMessage">message</see>. + </summary> + <param name="message"><see cref="T:System.Net.Mail.MailMessage">Message</see> instance</param> + </member> + <member name="M:Castle.Core.Smtp.IEmailSender.Send(System.Collections.Generic.IEnumerable{System.Net.Mail.MailMessage})"> + <summary> + Sends multiple <see cref="T:System.Net.Mail.MailMessage">messages</see>. + </summary> + <param name="messages">List of <see cref="T:System.Net.Mail.MailMessage">messages</see></param> + </member> + <member name="M:Castle.Core.Smtp.DefaultSmtpSender.#ctor(System.String)"> + <summary> + This service implementation + requires a host name in order to work + </summary> + <param name="hostname">The smtp server name</param> + </member> + <member name="M:Castle.Core.Smtp.DefaultSmtpSender.Send(System.String,System.String,System.String,System.String)"> + <summary> + Sends a message. + </summary> + <exception cref="T:System.ArgumentNullException">If any of the parameters is null</exception> + <param name="from">From field</param> + <param name="to">To field</param> + <param name="subject">e-mail's subject</param> + <param name="messageText">message's body</param> + </member> + <member name="M:Castle.Core.Smtp.DefaultSmtpSender.Send(System.Net.Mail.MailMessage)"> + <summary> + Sends a message. + </summary> + <exception cref="T:System.ArgumentNullException">If the message is null</exception> + <param name="message">Message instance</param> + </member> + <member name="M:Castle.Core.Smtp.DefaultSmtpSender.Configure(System.Net.Mail.SmtpClient)"> + <summary> + Configures the sender + with port information and eventual credential + informed + </summary> + <param name="smtpClient">Message instance</param> + </member> + <member name="P:Castle.Core.Smtp.DefaultSmtpSender.Port"> + <summary> + Gets or sets the port used to + access the SMTP server + </summary> + </member> + <member name="P:Castle.Core.Smtp.DefaultSmtpSender.Hostname"> + <summary> + Gets the hostname. + </summary> + <value>The hostname.</value> + </member> + <member name="P:Castle.Core.Smtp.DefaultSmtpSender.AsyncSend"> + <summary> + Gets or sets a value which is used to + configure if emails are going to be sent asyncrhonously or not. + </summary> + </member> + <member name="P:Castle.Core.Smtp.DefaultSmtpSender.Timeout"> + <summary> + Gets or sets a value that specifies + the amount of time after which a synchronous Send call times out. + </summary> + </member> + <member name="P:Castle.Core.Smtp.DefaultSmtpSender.UseSsl"> + <summary> + Gets or sets a value indicating whether the email should be sent using + a secure communication channel. + </summary> + <value><c>true</c> if should use SSL; otherwise, <c>false</c>.</value> + </member> + <member name="P:Castle.Core.Smtp.DefaultSmtpSender.Domain"> + <summary> + Gets or sets the domain. + </summary> + <value>The domain.</value> + </member> + <member name="P:Castle.Core.Smtp.DefaultSmtpSender.UserName"> + <summary> + Gets or sets the name of the user. + </summary> + <value>The name of the user.</value> + </member> + <member name="P:Castle.Core.Smtp.DefaultSmtpSender.Password"> + <summary> + Gets or sets the password. + </summary> + <value>The password.</value> + </member> + <member name="P:Castle.Core.Smtp.DefaultSmtpSender.HasCredentials"> + <summary> + Gets a value indicating whether credentials were informed. + </summary> + <value> + <see langword="true"/> if this instance has credentials; otherwise, <see langword="false"/>. + </value> + </member> <member name="T:Castle.Core.IServiceEnabledComponent"> <summary> Defines that the implementation wants a Modified: trunk/nhibernate/lib/net/3.5/Castle.DynamicProxy2.dll =================================================================== (Binary files differ) Modified: trunk/nhibernate/lib/net/3.5/Castle.DynamicProxy2.xml =================================================================== --- trunk/nhibernate/lib/net/3.5/Castle.DynamicProxy2.xml 2010-01-27 15:58:40 UTC (rev 4940) +++ trunk/nhibernate/lib/net/3.5/Castle.DynamicProxy2.xml 2010-02-01 12:06:34 UTC (rev 4941) @@ -4,42 +4,42 @@ <name>Castle.DynamicProxy2</name> </assembly> <members> - <member name="T:Castle.DynamicProxy.Generators.Emitters.SimpleAST.IndirectReference"> + <member name="M:Castle.DynamicProxy.Contributors.MembersCollector.IsAccessible(System.Reflection.MethodBase)"> <summary> - Wraps a reference that is passed - ByRef and provides indirect load/store support. + Checks if the method is public or protected. </summary> + <param name="method"></param> + <returns></returns> </member> - <member name="T:Castle.DynamicProxy.Generators.Emitters.SimpleAST.NewArrayExpression"> + <member name="M:Castle.DynamicProxy.Contributors.MembersCollector.AcceptMethod(System.Reflection.MethodInfo,System.Boolean,Castle.DynamicProxy.IProxyGenerationHook)"> <summary> - Summary description for NewArrayExpression. + Performs some basic screening and invokes the <see cref="T:Castle.DynamicProxy.IProxyGenerationHook"/> + to select methods. </summary> + <param name="method"></param> + <param name="onlyVirtuals"></param> + <param name="hook"></param> + <returns></returns> </member> - <member name="T:Castle.DynamicProxy.Generators.Emitters.SimpleAST.ReferencesToObjectArrayExpression"> + <member name="T:Castle.DynamicProxy.Contributors.ITypeContributor"> <summary> - + Interface describing elements composing generated type </summary> </member> - <member name="M:Castle.DynamicProxy.Generators.Emitters.CustomAttributeUtil.InitializeConstructorArgs(System.Type,System.Attribute,System.Object[],System.Reflection.ParameterInfo[])"> + <member name="T:Castle.DynamicProxy.Generators.Emitters.SimpleAST.IndirectReference"> <summary> - Here we try to match a constructor argument to its value. - Since we can't get the values from the assembly, we use some heuristics to get it. - a/ we first try to match all the properties on the attributes by name (case insensitive) to the argument - b/ if we fail we try to match them by property type, with some smarts about convertions (i,e: can use Guid for string). + Wraps a reference that is passed + ByRef and provides indirect load/store support. </summary> </member> - <member name="M:Castle.DynamicProxy.Generators.Emitters.CustomAttributeUtil.ReplaceIfBetterMatch(System.Reflection.ParameterInfo,System.Reflection.PropertyInfo,System.Reflection.PropertyInfo)"> + <member name="T:Castle.DynamicProxy.Generators.Emitters.SimpleAST.NewArrayExpression"> <summary> - We have the following rules here. - Try to find a matching type, failing that, if the parameter is string, get the first property (under the assumption that - we can convert it. + Summary description for NewArrayExpression. </summary> </member> - <member name="M:Castle.DynamicProxy.Generators.Emitters.CustomAttributeUtil.ConvertValue(System.Object,System.Type)"> + <member name="T:Castle.DynamicProxy.Generators.Emitters.SimpleAST.ReferencesToObjectArrayExpression"> <summary> - Attributes can only accept simple types, so we return null for null, - if the value is passed as string we call to string (should help with converting), - otherwise, we use the value as is (enums, integer, etc). + </summary> </member> <member name="T:Castle.DynamicProxy.Generators.Emitters.LdcOpCodesDictionary"> @@ -103,161 +103,138 @@ for the type of primitive value to be stored indirectly. </summary> </member> - <member name="T:Castle.DynamicProxy.Generators.BaseProxyGenerator"> + <member name="M:Castle.DynamicProxy.Generators.Emitters.TypeUtil.GetAllInterfaces(System.Type[])"> <summary> - Base class that exposes the common functionalities - to proxy generation. + Returns list of all unique interfaces implemented given types, including their base interfaces. </summary> - <remarks> - TODO: - - Add tests and fixes for 'leaking this' problem - </remarks> - </member> - <member name="M:Castle.DynamicProxy.Generators.BaseProxyGenerator.GetProxyTargetReference"> - <summary> - Used by dinamically implement <see cref="T:Castle.Core.Interceptor.IProxyTargetAccessor"/> - </summary> + <param name="types"></param> <returns></returns> </member> - <member name="M:Castle.DynamicProxy.Generators.BaseProxyGenerator.GenerateParameterlessConstructor(Castle.DynamicProxy.Generators.Emitters.ClassEmitter,System.Type,Castle.DynamicProxy.Generators.Emitters.SimpleAST.FieldReference)"> + <member name="M:Castle.DynamicProxy.Generators.AttributeDisassembler.HandleError(System.Type,System.Exception)"> <summary> - Generates a parameters constructor that initializes the proxy - state with <see cref="T:Castle.Core.Interceptor.StandardInterceptor"/> just to make it non-null. - <para> - This constructor is important to allow proxies to be XML serializable - </para> + Handles error during disassembly process </summary> + <param name="attributeType">Type of the attribute being disassembled</param> + <param name="exception">Exception thrown during the process</param> + <returns>usually null, or (re)throws the exception</returns> </member> - <member name="M:Castle.DynamicProxy.Generators.BaseProxyGenerator.BuildInvocationNestedType(Castle.DynamicProxy.Generators.Emitters.ClassEmitter,System.Type,System.Type,System.Reflection.MethodInfo,System.Reflection.MethodInfo,Castle.DynamicProxy.Generators.ConstructorVersion)"> + <member name="M:Castle.DynamicProxy.Generators.AttributeDisassembler.InitializeConstructorArgs(System.Type,System.Attribute,System.Object[],System.Reflection.ParameterInfo[])"> <summary> - If callbackMethod is null the InvokeOnTarget implementation - is just the code to throw an exception + Here we try to match a constructor argument to its value. + Since we can't get the values from the assembly, we use some heuristics to get it. + a/ we first try to match all the properties on the attributes by name (case insensitive) to the argument + b/ if we fail we try to match them by property type, with some smarts about convertions (i,e: can use Guid for string). </summary> - <param name="emitter"></param> - <param name="targetType"></param> - <param name="targetForInvocation"></param> - <param name="methodInfo"></param> - <param name="callbackMethod"></param> - <param name="version"></param> - <returns></returns> </member> - <member name="M:Castle.DynamicProxy.Generators.BaseProxyGenerator.BuildInvocationNestedType(Castle.DynamicProxy.Generators.Emitters.ClassEmitter,System.Type,System.Type,System.Reflection.MethodInfo,System.Reflection.MethodInfo,Castle.DynamicProxy.Generators.ConstructorVersion,System.Boolean)"> + <member name="M:Castle.DynamicProxy.Generators.AttributeDisassembler.ReplaceIfBetterMatch(System.Reflection.ParameterInfo,System.Reflection.PropertyInfo,System.Reflection.PropertyInfo)"> <summary> - If callbackMethod is null the InvokeOnTarget implementation - is just the code to throw an exception + We have the following rules here. + Try to find a matching type, failing that, if the parameter is string, get the first property (under the assumption that + we can convert it. </summary> - <param name="emitter"></param> - <param name="targetType"></param> - <param name="targetForInvocation"></param> - <param name="methodInfo"></param> - <param name="callbackMethod"></param> - <param name="version"></param> - <param name="allowChangeTarget">If true the invocation will implement the IChangeProxyTarget interface</param> - <returns></returns> </member> - <member name="M:Castle.DynamicProxy.Generators.BaseProxyGenerator.CreateIInvocationConstructor(System.Type,Castle.DynamicProxy.Generators.Emitters.NestedClassEmitter,Castle.DynamicProxy.Generators.Emitters.SimpleAST.FieldReference,Castle.DynamicProxy.Generators.ConstructorVersion)"> + <member name="M:Castle.DynamicProxy.Generators.AttributeDisassembler.ConvertValue(System.Object,System.Type)"> <summary> - Generates the constructor for the nested class that extends - <see cref="T:Castle.DynamicProxy.AbstractInvocation"/> + Attributes can only accept simple types, so we return null for null, + if the value is passed as string we call to string (should help with converting), + otherwise, we use the value as is (enums, integer, etc). </summary> - <param name="targetFieldType"></param> - <param name="nested"></param> - <param name="targetField"></param> - <param name="version"></param> </member> - <member name="M:Castle.DynamicProxy.Generators.BaseProxyGenerator.CreateInitializeCacheMethodBody(System.Type,System.Reflection.MethodInfo[],Castle.DynamicProxy.Generators.Emitters.ClassEmitter,Castle.DynamicProxy.Generators.Emitters.ConstructorEmitter)"> + <member name="T:Castle.DynamicProxy.Generators.BaseProxyGenerator"> <summary> - Improvement: this cache should be static. We should generate a - type constructor instead + Base class that exposes the common functionalities + to proxy generation. </summary> </member> - <member name="M:Castle.DynamicProxy.Generators.BaseProxyGenerator.AcceptMethod(System.Reflection.MethodInfo,System.Boolean)"> + <member name="M:Castle.DynamicProxy.Generators.BaseProxyGenerator.GenerateParameterlessConstructor(Castle.DynamicProxy.Generators.Emitters.ClassEmitter,System.Type,Castle.DynamicProxy.Generators.Emitters.SimpleAST.FieldReference)"> <summary> - Performs some basic screening and invokes the <see cref="T:Castle.DynamicProxy.IProxyGenerationHook"/> - to select methods. + Generates a parameters constructor that initializes the proxy + state with <see cref="T:Castle.Core.Interceptor.StandardInterceptor"/> just to make it non-null. + <para> + This constructor is important to allow proxies to be XML serializable + </para> </summary> - <param name="method"></param> - <param name="onlyVirtuals"></param> - <returns></returns> </member> - <member name="M:Castle.DynamicProxy.Generators.BaseProxyGenerator.IsAccessible(System.Reflection.MethodInfo)"> + <member name="M:Castle.DynamicProxy.Generators.BaseProxyGenerator.AddMappingNoCheck(System.Type,Castle.DynamicProxy.Contributors.ITypeContributor,System.Collections.Generic.IDictionary{System.Type,Castle.DynamicProxy.Contributors.ITypeContributor})"> <summary> - Checks if the method is public or protected. + It is safe to add mapping (no mapping for the interface exists) </summary> - <param name="method"></param> - <returns></returns> + <param name="implementer"></param> + <param name="interface"></param> + <param name="mapping"></param> </member> - <member name="M:Castle.DynamicProxy.Generators.BaseProxyGenerator.ShouldSkipAttributeReplication(System.Attribute)"> + <member name="M:Castle.DynamicProxy.Generators.CacheKey.#ctor(System.Reflection.MemberInfo,System.Type,System.Type[],Castle.DynamicProxy.ProxyGenerationOptions)"> <summary> - Attributes should be replicated if they are non-inheritable, - but there are some special cases where the attributes means - something to the CLR, where they should be skipped. + Initializes a new instance of the <see cref="T:Castle.DynamicProxy.Generators.CacheKey"/> class. </summary> + <param name="target">Target element. This is either target type or target method for invocation types.</param> + <param name="type">The type of the proxy. This is base type for invocation types.</param> + <param name="interfaces">The interfaces.</param> + <param name="options">The options.</param> </member> - <member name="M:Castle.DynamicProxy.Generators.BaseProxyGenerator.ShouldCreateNewSlot(System.Reflection.MethodInfo)"> - <summary> - Checks if the method has the same signature as a method that was marked as - one that should generate a new vtable slot. - </summary> - </member> <member name="M:Castle.DynamicProxy.Generators.CacheKey.#ctor(System.Type,System.Type[],Castle.DynamicProxy.ProxyGenerationOptions)"> <summary> Initializes a new instance of the <see cref="T:Castle.DynamicProxy.Generators.CacheKey"/> class. </summary> - <param name="targetType">Type of the target.</param> + <param name="target">Type of the target.</param> <param name="interfaces">The interfaces.</param> <param name="options">The options.</param> </member> - <member name="T:Castle.DynamicProxy.Generators.ClassProxyGenerator"> + <member name="M:Castle.DynamicProxy.Generators.InvocationTypeGenerator.GetCtorArgumentsAndBaseCtorToCall(System.Type,Castle.DynamicProxy.ProxyGenerationOptions,System.Reflection.ConstructorInfo@)"> <summary> - + Generates the constructor for the class that extends + <see cref="T:Castle.DynamicProxy.AbstractInvocation"/> </summary> + <param name="targetFieldType"></param> + <param name="proxyGenerationOptions"></param> + <param name="baseConstructor"></param> </member> - <member name="M:Castle.DynamicProxy.Generators.EventToGenerate.#ctor(Castle.DynamicProxy.Generators.Emitters.EventEmitter,System.Reflection.MethodInfo,System.Reflection.MethodInfo,System.Reflection.EventAttributes)"> + <member name="T:Castle.DynamicProxy.Generators.ClassProxyGenerator"> <summary> - Initializes a new instance of the <see cref="T:Castle.DynamicProxy.Generators.EventToGenerate"/> class. + </summary> - <param name="emitter">The emitter.</param> - <param name="addMethod">The add method.</param> - <param name="removeMethod">The remove method.</param> - <param name="attributes">The attributes.</param> </member> - <member name="T:Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator"> + <member name="T:Castle.DynamicProxy.Generators.INamingScope"> <summary> - + Represents the scope of uniquenes of names for types and their members </summary> </member> - <member name="M:Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator.FindMethodOnTargetType(System.Reflection.MethodInfo,System.Type,System.Boolean)"> + <member name="M:Castle.DynamicProxy.Generators.INamingScope.GetUniqueName(System.String)"> <summary> - Finds the type of the method on target. + Gets a unique name based on <paramref name="suggestedName"/> </summary> - <param name="methodOnInterface">The method on interface.</param> - <param name="proxyTargetType">Type of the proxy target.</param> - /// <param name="checkMixins">if set to <c>true</c> will check implementation on mixins.</param> - <returns></returns> + <param name="suggestedName">Name suggested by the caller</param> + <returns>Unique name based on <paramref name="suggestedName"/>.</returns> + <remarks> + Implementers should provide name as closely resembling <paramref name="suggestedName"/> as possible. + Generally if no collision occurs it is suggested to return suggested name, otherwise append sequential suffix. + Implementers must return deterministic names, that is when <see cref="M:Castle.DynamicProxy.Generators.INamingScope.GetUniqueName(System.String)"/> is called twice + with the same suggested name, the same returned name should be provided each time. Non-deterministic return + values, like appending random suffices will break serialization of proxies. + </remarks> </member> - <member name="M:Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator.IsTypeEquivalent(System.Type,System.Type)"> + <member name="M:Castle.DynamicProxy.Generators.INamingScope.SafeSubScope"> <summary> - Checks whether the given types are the same. This is - more complicated than it looks. + Returns new, disposable naming scope. It is responsibilty of the caller to make sure that no naming collision + with enclosing scope, or other subscopes is possible. </summary> - <param name="sourceType"></param> - <param name="targetType"></param> - <returns></returns> + <returns>New naming scope.</returns> </member> - <member name="M:Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator.IsMethodEquivalent(System.Reflection.MethodInfo,System.Reflection.MethodInfo)"> + <member name="T:Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator"> <summary> - Checks whether the given methods are the same. + </summary> - <param name="methodInfo"></param> - <param name="methodOnInterface"></param> - <returns>True if the methods are the same.</returns> </member> - <member name="T:Castle.DynamicProxy.Generators.InterfaceGeneratorType"> + <member name="M:Castle.DynamicProxy.Generators.MetaEvent.#ctor(System.String,System.Type,System.Type,Castle.DynamicProxy.Generators.MetaMethod,Castle.DynamicProxy.Generators.MetaMethod,System.Reflection.EventAttributes)"> <summary> - This is used by the ProxyObjectReference class durin de-serialiation, to know - which generator it should use + Initializes a new instance of the <see cref="T:Castle.DynamicProxy.Generators.MetaEvent"/> class. </summary> + <param name="name">The name.</param> + <param name="declaringType">Type declaring the original event being overriten, or null.</param> + <param name="eventDelegateType"></param> + <param name="adder">The add method.</param> + <param name="remover">The remove method.</param> + <param name="attributes">The attributes.</param> </member> <member name="T:Castle.DynamicProxy.Generators.MethodFinder"> <summary> @@ -292,6 +269,41 @@ might use more than one scope at the same time), <see cref="T:Castle.DynamicProxy.Serialization.ProxyObjectReference"/> uses a dedicated scope instance for deserializing proxy types. This instance can be reset and set to a specific value via <see cref="M:Castle.DynamicProxy.Serialization.ProxyObjectReference.ResetScope"/> and <see cref="M:Castle.DynamicProxy.Serialization.ProxyObjectReference.SetScope(Castle.DynamicProxy.ModuleScope)"/>.</value> </member> + <member name="T:Castle.DynamicProxy.Tokens.InvocationMethods"> + <summary> + Holds <see cref="T:System.Reflection.MethodInfo"/> objects representing methods of <see cref="T:Castle.DynamicProxy.AbstractInvocation"/> class. + </summary> + </member> + <member name="T:Castle.DynamicProxy.Tokens.SerializationInfoMethods"> + <summary> + Holds <see cref="T:System.Reflection.MethodInfo"/> objects representing methods of <see cref="T:System.Runtime.Serialization.SerializationInfo"/> class. + </summary> + </member> + <member name="F:Castle.DynamicProxy.Tokens.SerializationInfoMethods.AddValue_Bool"> + <summary> + <see cref="M:System.Runtime.Serialization.SerializationInfo.AddValue(System.String,System.Boolean)"/> + </summary> + </member> + <member name="F:Castle.DynamicProxy.Tokens.SerializationInfoMethods.AddValue_Int32"> + <summary> + <see cref="M:System.Runtime.Serialization.SerializationInfo.AddValue(System.String,System.Int32)"/> + </summary> + </member> + <member name="F:Castle.DynamicProxy.Tokens.SerializationInfoMethods.AddValue_Object"> + <summary> + <see cref="M:System.Runtime.Serialization.SerializationInfo.AddValue(System.String,System.Object)"/> + </summary> + </member> + <member name="F:Castle.DynamicProxy.Tokens.SerializationInfoMethods.GetValue"> + <summary> + <see cref="M:System.Runtime.Serialization.SerializationInfo.GetValue(System.String,System.Type)"/> + </summary> + </member> + <member name="F:Castle.DynamicProxy.Tokens.SerializationInfoMethods.SetType"> + <summary> + <see cref="M:System.Runtime.Serialization.SerializationInfo.SetType(System.Type)"/> + </summary> + </member> <member name="T:Castle.DynamicProxy.IProxyGenerationHook"> <summary> Used during the target type inspection process. Implementors have a chance to customize the @@ -323,6 +335,24 @@ Invoked by the generation process to notify that the whole process has completed. </summary> </member> + <member name="M:Castle.DynamicProxy.AttributeUtil.AddDisassembler``1(Castle.DynamicProxy.IAttributeDisassembler)"> + <summary> + Registers custom disassembler to handle disassembly of specified type of attributes. + </summary> + <typeparam name="TAttribute">Type of attributes to handle</typeparam> + <param name="disassembler">Disassembler converting existing instances of Attributes to CustomAttributeBuilders</param> + <remarks> + When disassembling an attribute Dynamic Proxy will first check if an custom disassembler has been registered to handle attributes of that type, + and if none is found, it'll use the <see cref="P:Castle.DynamicProxy.AttributeUtil.FallbackDisassembler"/>. + </remarks> + </member> + <member name="M:Castle.DynamicProxy.AttributeUtil.ShouldSkipAttributeReplication(System.Type)"> + <summary> + Attributes should be replicated if they are non-inheritable, + but there are some special cases where the attributes means + something to the CLR, where they should be skipped. + </summary> + </member> <member name="T:Castle.DynamicProxy.CacheMappingsAttribute"> <summary> Applied to the assemblies saved by <see cref="T:Castle.DynamicProxy.ModuleScope"/> in order to persist the cache data included in the persisted assembly. @@ -369,6 +399,24 @@ pointing to Castle Dynamic Proxy assembly, in assembly containing that type, if this is appropriate.</exception> <seealso cref="T:Castle.DynamicProxy.Generators.ClassProxyGenerator"/> </member> + <member name="M:Castle.DynamicProxy.IProxyBuilder.CreateClassProxyType(System.Type,System.Type[],Castle.DynamicProxy.ProxyGenerationOptions)"> + <summary> + Creates a proxy type for given <paramref name="classToProxy"/>, implementing <paramref name="additionalInterfacesToProxy"/>, using <paramref name="options"/> provided. + </summary> + <param name="classToProxy">The class type to proxy.</param> + <param name="additionalInterfacesToProxy">Additional interface types to proxy.</param> + <param name="options">The proxy generation options.</param> + <returns>The generated proxy type.</returns> + <remarks> + Implementers should return a proxy type for the specified class and interfaces. + Additional interfaces should be only 'mark' interfaces, that is, they should work like interface proxy without target. (See <see cref="M:Castle.DynamicProxy.IProxyBuilder.CreateInterfaceProxyTypeWithoutTarget(System.Type,System.Type[],Castle.DynamicProxy.ProxyGenerationOptions)"/> method.) + </remarks> + <exception cref="T:Castle.DynamicProxy.Generators.GeneratorException">Thrown when <paramref name="classToProxy"/> or any of <paramref name="additionalInterfacesToProxy"/> is a generic type definition.</exception> + <exception cref="T:Castle.DynamicProxy.Generators.GeneratorException">Thrown when <paramref name="classToProxy"/> or any of <paramref name="additionalInterfacesToProxy"/> is not public. + Note that to avoid this exception, you can mark offending type internal, and define <see cref="T:System.Runtime.CompilerServices.InternalsVisibleToAttribute"/> + pointing to Castle Dynamic Proxy assembly, in assembly containing that type, if this is appropriate.</exception> + <seealso cref="T:Castle.DynamicProxy.Generators.ClassProxyGenerator"/> + </member> <member name="M:Castle.DynamicProxy.IProxyBuilder.CreateInterfaceProxyTypeWithTarget(System.Type,System.Type[],System.Type,Castle.DynamicProxy.ProxyGenerationOptions)"> <summary> Creates a proxy type that proxies calls to <paramref name="interfaceToProxy"/> members on <paramref name="targetType"/>, implementing <paramref name="additionalInterfacesToProxy"/>, using <paramref name="options"/> provided. @@ -424,6 +472,11 @@ pointing to Castle Dynamic Proxy assembly, in assembly containing that type, if this is appropriate.</exception> <seealso cref="T:Castle.DynamicProxy.Generators.InterfaceProxyWithTargetInterfaceGenerator"/> </member> + <member name="P:Castle.DynamicProxy.IProxyBuilder.Logger"> + <summary> + Gets or sets the <see cref="T:Castle.Core.Logging.ILogger"/> that this <see cref="T:Castle.DynamicProxy.ProxyGenerator"/> logs to. + </summary> + </member> <member name="P:Castle.DynamicProxy.IProxyBuilder.ModuleScope"> <summary> Gets the <see cref="P:Castle.DynamicProxy.IProxyBuilder.ModuleScope"/> associated with this builder. @@ -441,33 +494,6 @@ </summary> <param name="scope">The module scope for generated proxy types.</param> </member> - <member name="T:Castle.DynamicProxy.IInterceptorSelector"> - <summary> - Provides an extension point that allows proxies to choose specific interceptors on - a per method basis. - </summary> - </member> - <member name="M:Castle.DynamicProxy.IInterceptorSelector.SelectInterceptors(System.Type,System.Reflection.MethodInfo,Castle.Core.Interceptor.IInterceptor[])"> - <summary> - Selects the interceptors that should intercept calls to the given <paramref name="method"/>. - </summary> - <param name="type">The type declaring the method to intercept.</param> - <param name="method">The method that will be intercepted.</param> - <param name="interceptors">All interceptors registered with the proxy.</param> - <returns>An array of interceptors to invoke upon calling the <paramref name="method"/>.</returns> - <remarks> - This method is called only once per proxy instance, upon the first call to the - <paramref name="method"/>. Either an empty array or null are valid return values to indicate - that no interceptor should intercept calls to the method. Although it is not advised, it is - legal to return other <see cref="T:Castle.Core.Interceptor.IInterceptor"/> implementations than these provided in - <paramref name="interceptors"/>. A better way to do this, is by passing all the required - interceptors to the appropriate method of <see cref="T:Castle.DynamicProxy.ProxyGenerator"/>. You can use this - method to influence the order in which interceptors will be called, by reordering the array. - Returning an array containing null references (Nothing in Visual Basic) is not legal, - and will result in a runtime exception. - </remarks> - <seealso cref="T:Castle.DynamicProxy.ProxyGenerationOptions"/> - </member> <member name="M:Castle.DynamicProxy.InternalsHelper.IsInternalToDynamicProxy(System.Reflection.Assembly)"> <summary> Determines whether this assembly has internals visible to dynamic proxy. @@ -532,6 +558,18 @@ <param name="weakAssemblyName">The simple name of the weak-named assembly generated by this <see cref="T:Castle.DynamicProxy.ModuleScope"/>.</param> <param name="weakModulePath">The path and file name of the manifest module of the weak-named assembly generated by this <see cref="T:Castle.DynamicProxy.ModuleScope"/>.</param> </member> + <member name="M:Castle.DynamicProxy.ModuleScope.#ctor(System.Boolean,Castle.DynamicProxy.Generators.INamingScope,System.String,System.String,System.String,System.String)"> + <summary> + Initializes a new instance of the <see cref="T:Castle.DynamicProxy.ModuleScope"/> class, allowing to specify whether the assemblies generated by this instance + should be saved and what simple names are to be assigned to them. + </summary> + <param name="savePhysicalAssembly">If set to <c>true</c> saves the generated module.</param> + <param name="namingScope">Naming scope used to provide unique names to generated types and their members (usually via sub-scopes).</param> + <param name="strongAssemblyName">The simple name of the strong-named assembly generated by this <see cref="T:Castle.DynamicProxy.ModuleScope"/>.</param> + <param name="strongModulePath">The path and file name of the manifest module of the strong-named assembly generated by this <see cref="T:Castle.DynamicProxy.ModuleScope"/>.</param> + <param name="weakAssemblyName">The simple name of the weak-named assembly generated by this <see cref="T:Castle.DynamicProxy.ModuleScope"/>.</param> + <param name="weakModulePath">The path and file name of the manifest module of the weak-named assembly generated by this <see cref="T:Castle.DynamicProxy.ModuleScope"/>.</param> + </member> <member name="M:Castle.DynamicProxy.ModuleScope.GetFromCache(Castle.DynamicProxy.Generators.CacheKey)"> <summary> Returns a type from this scope's type cache, or null if the key cannot be found. @@ -619,7 +657,7 @@ to avoid the performance hit associated with proxy generation. </remarks> </member> - <member name="P:Castle.DynamicProxy.ModuleScope.RWLock"> + <member name="P:Castle.DynamicProxy.ModuleScope.Lock"> <summary> Users of this <see cref="T:Castle.DynamicProxy.ModuleScope"/> should use this lock when accessing the cache. </summary> @@ -726,11 +764,13 @@ <exception cref="T:System.MissingMethodException">Thrown when no default constructor exists on actual type of <paramref name="target"/> object.</exception> <exception cref="T:System.Reflection.TargetInvocationException">Thrown when default constructor of actual type of <paramref name="target"/> throws an exception.</exception> <remarks> + This method generates new proxy type for each type of <paramref name="target"/>, which affects performance. If you don't want to proxy types differently depending on the type of the target + use <see cref="M:Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithTargetInterface``1(``0,Castle.Core.Interceptor.IInterceptor[])"/> method. This method uses <see cref="T:Castle.DynamicProxy.IProxyBuilder"/> implementation to generate a proxy type. As such caller should expect any type of exception that given <see cref="T:Castle.DynamicProxy.IProxyBuilder"/> implementation may throw. </remarks> </member> - <member name="M:Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithTarget``1(System.Object,Castle.DynamicProxy.ProxyGenerationOptions,Castle.Core.Interceptor.IInterceptor[])"> + <member name="M:Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithTarget``1(``0,Castle.DynamicProxy.ProxyGenerationOptions,Castle.Core.Interceptor.IInterceptor[])"> <summary> Creates proxy object intercepting calls to members of interface <typeparamref name="TInterface"/> on <paramref name="target"/> object with given <paramref name="interceptors"/>. </summary> @@ -747,6 +787,8 @@ <exception cref="T:System.MissingMethodException">Thrown when no default constructor exists on actual type of <paramref name="target"/> object.</exception> <exception cref="T:System.Reflection.TargetInvocationException">Thrown when default constructor of actual type of <paramref name="target"/> throws an exception.</exception> <remarks> + This method generates new proxy type for each type of <paramref name="target"/>, which affects performance. If you don't want to proxy types differently depending on the type of the target + use <see cref="M:Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithTargetInterface``1(``0,Castle.DynamicProxy.ProxyGenerationOptions,Castle.Core.Interceptor.IInterceptor[])"/> method. This method uses <see cref="T:Castle.DynamicProxy.IProxyBuilder"/> implementation to generate a proxy type. As such caller should expect any type of exception that given <see cref="T:Castle.DynamicProxy.IProxyBuilder"/> implementation may throw. </remarks> @@ -770,6 +812,8 @@ <exception cref="T:System.MissingMethodException">Thrown when no default constructor exists on actual type of <paramref name="target"/> object.</exception> <exception cref="T:System.Reflection.TargetInvocationException">Thrown when default constructor of actual type of <paramref name="target"/> throws an exception.</exception> <remarks> + This method generates new proxy type for each type of <paramref name="target"/>, which affects performance. If you don't want to proxy types differently depending on the type of the target + use <see cref="M:Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithTargetInterface(System.Type,System.Object,Castle.Core.Interceptor.IInterceptor[])"/> method. This method uses <see cref="T:Castle.DynamicProxy.IProxyBuilder"/> implementation to generate a proxy type. As such caller should expect any type of exception that given <see cref="T:Castle.DynamicProxy.IProxyBuilder"/> implementation may throw. </remarks> @@ -794,6 +838,8 @@ <exception cref="T:System.MissingMethodException">Thrown when no default constructor exists on actual type of <paramref name="target"/> object.</exception> <exception cref="T:System.Reflection.TargetInvocationException">Thrown when default constructor of actual type of <paramref name="target"/> throws an exception.</exception> <remarks> + This method generates new proxy type for each type of <paramref name="target"/>, which affects performance. If you don't want to proxy types differently depending on the type of the target + use <see cref="M:Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithTargetInterface(System.Type,System.Object,Castle.DynamicProxy.ProxyGenerationOptions,Castle.Core.Interceptor.IInterceptor[])"/> method. This method uses <see cref="T:Castle.DynamicProxy.IProxyBuilder"/> implementation to generate a proxy type. As such caller should expect any type of exception that given <see cref="T:Castle.DynamicProxy.IProxyBuilder"/> implementation may throw. </remarks> @@ -818,6 +864,8 @@ <exception cref="T:System.MissingMethodException">Thrown when no default constructor exists on actual type of <paramref name="target"/> object.</exception> <exception cref="T:System.Reflection.TargetInvocationException">Thrown when default constructor of actual type of <paramr... [truncated message content] |
From: Filip N. <ngu...@gm...> - 2010-01-30 12:59:59
|
asdf __________ Informace od ESET NOD32 Antivirus, verze databaze 4820 (20100130) __________ Tuto zpravu proveril ESET NOD32 Antivirus. http://www.eset.cz |
From: <aye...@us...> - 2010-01-27 15:58:58
|
Revision: 4940 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4940&view=rev Author: ayenderahien Date: 2010-01-27 15:58:40 +0000 (Wed, 27 Jan 2010) Log Message: ----------- NH-2074 - supporting unicode values in formula fields for SQL 2000 & up Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Model.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2010-01-27 15:19:39 UTC (rev 4939) +++ trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2010-01-27 15:58:40 UTC (rev 4940) @@ -17,7 +17,7 @@ using NHibernate.SqlTypes; using NHibernate.Type; using NHibernate.Util; -using Environment=NHibernate.Cfg.Environment; +using Environment = NHibernate.Cfg.Environment; namespace NHibernate.Dialect { @@ -67,8 +67,8 @@ { standardAggregateFunctions["count"] = new CountQueryFunctionInfo(); standardAggregateFunctions["avg"] = new AvgQueryFunctionInfo(); - standardAggregateFunctions["max"] = new ClassicAggregateFunction("max",false); - standardAggregateFunctions["min"] = new ClassicAggregateFunction("min",false); + standardAggregateFunctions["max"] = new ClassicAggregateFunction("max", false); + standardAggregateFunctions["min"] = new ClassicAggregateFunction("min", false); standardAggregateFunctions["sum"] = new SumQueryFunctionInfo(); Extracter = new NoOpViolatedConstraintNameExtracter(); @@ -151,7 +151,7 @@ { dialectName = Environment.Properties[Environment.Dialect]; } - catch(Exception e) + catch (Exception e) { throw new HibernateException("The dialect was not set. Set the property 'dialect'.", e); } @@ -171,7 +171,7 @@ throw new ArgumentNullException("props"); string dialectName; if (props.TryGetValue(Environment.Dialect, out dialectName) == false) - throw new InvalidOperationException("Could not find the dialect in the configuration"); + throw new InvalidOperationException("Could not find the dialect in the configuration"); if (dialectName == null) { return GetDialect(); @@ -184,7 +184,7 @@ { try { - return (Dialect) Environment.BytecodeProvider.ObjectsFactory.CreateInstance(ReflectHelper.ClassForName(dialectName)); + return (Dialect)Environment.BytecodeProvider.ObjectsFactory.CreateInstance(ReflectHelper.ClassForName(dialectName)); } catch (Exception e) { @@ -270,7 +270,7 @@ /// <returns> The appropriate command. </returns> public virtual string SelectGUIDString { - get{throw new NotSupportedException("dialect does not support server side GUIDs generation.");} + get { throw new NotSupportedException("dialect does not support server side GUIDs generation."); } } /// <summary> Command used to create a table. </summary> @@ -307,7 +307,7 @@ /// </summary> public virtual string CreateTemporaryTablePostfix { - get{return string.Empty;} + get { return string.Empty; } } /// <summary> @@ -397,13 +397,13 @@ get { return String.Empty; } } - /// <summary> - /// The keyword used to create a primary key constraint - /// </summary> - public virtual string PrimaryKeyString - { - get { return "primary key"; } - } + /// <summary> + /// The keyword used to create a primary key constraint + /// </summary> + public virtual string PrimaryKeyString + { + get { return "primary key"; } + } #region database type mapping support @@ -415,7 +415,7 @@ /// <returns>The database type name used by ddl.</returns> public virtual string GetTypeName(SqlType sqlType) { - if (sqlType.LengthDefined || sqlType.PrecisionDefined) + if (sqlType.LengthDefined || sqlType.PrecisionDefined) { string resultWithLength = typeNames.Get(sqlType.DbType, sqlType.Length, sqlType.Precision, sqlType.Scale); if (resultWithLength != null) return resultWithLength; @@ -1473,7 +1473,7 @@ return (name[0] == OpenQuote && name[name.Length - 1] == CloseQuote); } - public virtual string Qualify(string catalog, string schema, string table) + public virtual string Qualify(string catalog, string schema, string table) { StringBuilder qualifiedName = new StringBuilder(); @@ -1533,8 +1533,8 @@ public virtual string QuoteForAliasName(string aliasName) { return IsQuoted(aliasName) ? - aliasName : - Quote(aliasName); + aliasName : + Quote(aliasName); } /// <summary> @@ -1554,8 +1554,8 @@ public virtual string QuoteForColumnName(string columnName) { return IsQuoted(columnName) ? - columnName : - Quote(columnName); + columnName : + Quote(columnName); } /// <summary> @@ -1574,8 +1574,8 @@ public virtual string QuoteForTableName(string tableName) { return IsQuoted(tableName) ? - tableName : - Quote(tableName); + tableName : + Quote(tableName); } /// <summary> @@ -1594,8 +1594,8 @@ public virtual string QuoteForSchemaName(string schemaName) { return IsQuoted(schemaName) ? - schemaName : - Quote(schemaName); + schemaName : + Quote(schemaName); } /// <summary> @@ -1963,7 +1963,8 @@ [Serializable] protected class CountQueryFunctionInfo : ClassicAggregateFunction { - public CountQueryFunctionInfo() : base("count",true) + public CountQueryFunctionInfo() + : base("count", true) { } @@ -1975,7 +1976,8 @@ [Serializable] protected class AvgQueryFunctionInfo : ClassicAggregateFunction { - public AvgQueryFunctionInfo() : base("avg",false) + public AvgQueryFunctionInfo() + : base("avg", false) { } @@ -2002,11 +2004,12 @@ return NHibernateUtil.Double; } } - + [Serializable] protected class SumQueryFunctionInfo : ClassicAggregateFunction { - public SumQueryFunctionInfo() : base("sum",false) + public SumQueryFunctionInfo() + : base("sum", false) { } @@ -2106,16 +2109,20 @@ } #endregion - /// <summary> - /// Supports splitting batches using GO T-SQL command - /// </summary> - /// <remarks> - /// Batches http://msdn.microsoft.com/en-us/library/ms175502.aspx - /// </remarks> - public virtual bool SupportsSqlBatches - { - get { return false; } - } + /// <summary> + /// Supports splitting batches using GO T-SQL command + /// </summary> + /// <remarks> + /// Batches http://msdn.microsoft.com/en-us/library/ms175502.aspx + /// </remarks> + public virtual bool SupportsSqlBatches + { + get { return false; } + } + public virtual bool IsKnownToken(string currentToken, string nextToken) + { + return false; + } } } Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2010-01-27 15:19:39 UTC (rev 4939) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2010-01-27 15:58:40 UTC (rev 4940) @@ -10,7 +10,7 @@ using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; -using Environment=NHibernate.Cfg.Environment; +using Environment = NHibernate.Cfg.Environment; namespace NHibernate.Dialect { @@ -106,7 +106,7 @@ RegisterFunction("left", new SQLFunctionTemplate(NHibernateUtil.String, "left(?1, ?2)")); RegisterFunction("right", new SQLFunctionTemplate(NHibernateUtil.String, "right(?1, ?2)")); - RegisterFunction("locate", new StandardSQLFunction("charindex", NHibernateUtil.Int32)); + RegisterFunction("locate", new StandardSQLFunction("charindex", NHibernateUtil.Int32)); RegisterFunction("current_timestamp", new NoArgSQLFunction("getdate", NHibernateUtil.DateTime, true)); @@ -128,7 +128,7 @@ RegisterFunction("trim", new AnsiTrimEmulationFunction()); RegisterFunction("iif", new SQLFunctionTemplate(null, "case when ?1 then ?2 else ?3 end")); - RegisterFunction("replace", new StandardSafeSQLFunction("replace",NHibernateUtil.String, 3)); + RegisterFunction("replace", new StandardSafeSQLFunction("replace", NHibernateUtil.String, 3)); RegisterKeyword("top"); RegisterKeyword("integer"); @@ -496,12 +496,17 @@ get { return true; } } - public override bool SupportsSqlBatches - { - get - { - return true; - } - } + public override bool SupportsSqlBatches + { + get + { + return true; + } + } + + public override bool IsKnownToken(string currentToken, string nextToken) + { + return currentToken == "n" && nextToken == "'"; // unicode character + } } } Modified: trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2010-01-27 15:19:39 UTC (rev 4939) +++ trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2010-01-27 15:58:40 UTC (rev 4940) @@ -312,6 +312,7 @@ Keywords.Contains(lcToken) || functionRegistry.HasFunction(lcToken) || dialect.Keywords.Contains(lcToken) || + dialect.IsKnownToken(lcToken, nextToken) || FunctionKeywords.Contains(lcToken); } Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074 ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Fixture.cs 2010-01-27 15:58:40 UTC (rev 4940) @@ -0,0 +1,25 @@ +using NHibernate.Dialect; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH2074 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + protected override bool AppliesTo(NHibernate.Dialect.Dialect dialect) + { + return dialect is MsSql2000Dialect; + } + + [Test] + public void CanQueryOnPropertyUsingUnicodeToken() + { + using (var s = OpenSession()) + { + s.CreateQuery("from Person").List(); + } + } + + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Mappings.hbm.xml 2010-01-27 15:58:40 UTC (rev 4940) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH2074"> + + <class name="Person"> + <id name="Id"> + <generator class="increment" /> + </id> + <property name="Name"/> + + <property name="CalculatedProperty" formula="(SELECT COUNT(*) FROM Person t WHERE t.Name = N'VALUE')" /> + + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2074/Model.cs 2010-01-27 15:58:40 UTC (rev 4940) @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH2074 +{ + public class Person + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual int CalculatedProperty { get; set; } + } + +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-01-27 15:19:39 UTC (rev 4939) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-01-27 15:58:40 UTC (rev 4940) @@ -700,6 +700,8 @@ <Compile Include="NHSpecificTest\NH2030\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2065\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2065\Model.cs" /> + <Compile Include="NHSpecificTest\NH2074\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2074\Model.cs" /> <Compile Include="NHSpecificTest\NH2077\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2077\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> @@ -2119,6 +2121,7 @@ <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2074\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2077\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2020\Mappings.hbm.xml" /> <EmbeddedResource Include="GhostProperty\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2010-01-27 15:19:45
|
Revision: 4939 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4939&view=rev Author: ayenderahien Date: 2010-01-27 15:19:39 +0000 (Wed, 27 Jan 2010) Log Message: ----------- Fixing NH-2073 - Adding support for detecting sequences in FirebirdDialect Applied Patch from Alex Fernando Pozzani Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/FirebirdDialect.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/FirebirdDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/FirebirdDialect.cs 2010-01-27 15:19:14 UTC (rev 4938) +++ trunk/nhibernate/src/NHibernate/Dialect/FirebirdDialect.cs 2010-01-27 15:19:39 UTC (rev 4939) @@ -253,5 +253,10 @@ { return new FirebirdDataBaseSchema(connection); } + + public override string QuerySequencesString + { + get { return "select RDB$GENERATOR_NAME from RDB$GENERATORS where (RDB$SYSTEM_FLAG is NULL) or (RDB$SYSTEM_FLAG <> 1)"; } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2010-01-27 15:19:20
|
Revision: 4938 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4938&view=rev Author: ayenderahien Date: 2010-01-27 15:19:14 +0000 (Wed, 27 Jan 2010) Log Message: ----------- Adding top keyword for Sybase (NH-2081) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/SybaseAdoNet12Dialect.cs trunk/nhibernate/src/NHibernate/Dialect/SybaseAnywhereDialect.cs trunk/nhibernate/src/NHibernate/Dialect/SybaseDialect.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/SybaseAdoNet12Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/SybaseAdoNet12Dialect.cs 2010-01-27 15:07:21 UTC (rev 4937) +++ trunk/nhibernate/src/NHibernate/Dialect/SybaseAdoNet12Dialect.cs 2010-01-27 15:19:14 UTC (rev 4938) @@ -35,6 +35,8 @@ /// <summary></summary> public SybaseAdoNet12Dialect() { + RegisterKeyword("top"); + DefaultProperties[Environment.ConnectionDriver] = "NHibernate.Driver.SybaseAdoNet12ClientDriver"; DefaultProperties[Environment.PrepareSql] = "true"; } Modified: trunk/nhibernate/src/NHibernate/Dialect/SybaseAnywhereDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/SybaseAnywhereDialect.cs 2010-01-27 15:07:21 UTC (rev 4937) +++ trunk/nhibernate/src/NHibernate/Dialect/SybaseAnywhereDialect.cs 2010-01-27 15:19:14 UTC (rev 4938) @@ -55,6 +55,8 @@ Types.CLOB, "TEXT" ); */ + RegisterKeyword("top"); + DefaultProperties[Environment.ConnectionDriver] = "NHibernate.Driver.ASAClientDriver"; DefaultProperties[Environment.PrepareSql] = "false"; } Modified: trunk/nhibernate/src/NHibernate/Dialect/SybaseDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/SybaseDialect.cs 2010-01-27 15:07:21 UTC (rev 4937) +++ trunk/nhibernate/src/NHibernate/Dialect/SybaseDialect.cs 2010-01-27 15:19:14 UTC (rev 4938) @@ -126,6 +126,8 @@ RegisterFunction("trim", new SQLFunctionTemplate(NHibernateUtil.String, "ltrim(rtrim(?1))")); RegisterFunction("locate", new CharIndexFunction()); + RegisterKeyword("top"); + DefaultProperties[Environment.ConnectionDriver] = "NHibernate.Driver.SybaseClientDriver"; DefaultProperties[Environment.PrepareSql] = "false"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |