|
From: <ste...@us...> - 2010-07-06 09:15:06
|
Revision: 4998
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4998&view=rev
Author: steverstrong
Date: 2010-07-06 09:14:59 +0000 (Tue, 06 Jul 2010)
Log Message:
-----------
Fixed semantics of .Single
Modified Paths:
--------------
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/ProcessSingle.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessFirst.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessFirst.cs 2010-07-03 14:46:23 UTC (rev 4997)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessFirst.cs 2010-07-06 09:14:59 UTC (rev 4998)
@@ -11,7 +11,9 @@
? ReflectionHelper.GetMethod(() => Queryable.FirstOrDefault<object>(null))
: ReflectionHelper.GetMethod(() => Queryable.First<object>(null));
- ProcessFirstOrSingle(firstMethod, queryModelVisitor, tree);
+ AddClientSideEval(firstMethod, queryModelVisitor, tree);
+
+ tree.AddAdditionalCriteria((q, p) => q.SetMaxResults(1));
}
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessFirstOrSingleBase.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessFirstOrSingleBase.cs 2010-07-03 14:46:23 UTC (rev 4997)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessFirstOrSingleBase.cs 2010-07-06 09:14:59 UTC (rev 4998)
@@ -5,7 +5,7 @@
{
public class ProcessFirstOrSingleBase
{
- protected static void ProcessFirstOrSingle(MethodInfo target, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree)
+ protected static void AddClientSideEval(MethodInfo target, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree)
{
target = target.MakeGenericMethod(queryModelVisitor.CurrentEvaluationType.DataType);
@@ -17,7 +17,6 @@
parameter),
parameter);
- tree.AddAdditionalCriteria((q, p) => q.SetMaxResults(1));
tree.AddPostExecuteTransformer(lambda);
}
}
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessSingle.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessSingle.cs 2010-07-03 14:46:23 UTC (rev 4997)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessSingle.cs 2010-07-06 09:14:59 UTC (rev 4998)
@@ -11,7 +11,7 @@
? ReflectionHelper.GetMethod(() => Queryable.SingleOrDefault<object>(null))
: ReflectionHelper.GetMethod(() => Queryable.Single<object>(null));
- ProcessFirstOrSingle(firstMethod, queryModelVisitor, tree);
+ AddClientSideEval(firstMethod, queryModelVisitor, tree);
}
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-07-03 14:46:23 UTC (rev 4997)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-07-06 09:14:59 UTC (rev 4998)
@@ -1,4 +1,5 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -43,35 +44,35 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Antlr3.Runtime, Version=3.1.0.39271, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7, processorArchitecture=MSIL">
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Data.OracleClient" />
+ <Reference Include="System.ServiceModel">
+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Transactions" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Antlr3.Runtime, Version=3.1.0.39271, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\net\3.5\Antlr3.Runtime.dll</HintPath>
</Reference>
- <Reference Include="Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
+ <Reference Include="Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\net\3.5\Iesi.Collections.dll</HintPath>
</Reference>
- <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
+ <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\net\3.5\log4net.dll</HintPath>
</Reference>
- <Reference Include="Remotion.Data.Linq, Version=1.13.9.2, Culture=neutral, PublicKeyToken=cab60358ab4081ea, processorArchitecture=MSIL">
+ <Reference Include="Remotion.Data.Linq, Version=1.13.41.2, Culture=neutral, PublicKeyToken=cab60358ab4081ea">
<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">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data" />
- <Reference Include="System.Data.OracleClient" />
- <Reference Include="System.ServiceModel">
- <RequiredTargetFramework>3.0</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Transactions" />
- <Reference Include="System.Web" />
- <Reference Include="System.Xml" />
+ <Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup>
<Compile Include="ADOException.cs" />
Modified: trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs 2010-07-03 14:46:23 UTC (rev 4997)
+++ trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs 2010-07-06 09:14:59 UTC (rev 4998)
@@ -82,6 +82,14 @@
select user).Single();
}
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void SingleElementWithQueryThatReturnsMultipleResults()
+ {
+ var query = (from user in db.Users
+ select user).Single();
+ }
+
[Test]
public void SingleOrDefaultElementWithQueryThatReturnsNoResults()
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|