File tree Expand file tree Collapse file tree 5 files changed +93
-2
lines changed
NHibernate/Linq/NestedSelects Expand file tree Collapse file tree 5 files changed +93
-2
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Text ;
5
+
6
+ namespace NHibernate . Test . NHSpecificTest . NH3614
7
+ {
8
+ public class Entity
9
+ {
10
+ public virtual int Id { get ; protected set ; }
11
+ public virtual IList < string > SomeStrings { get ; set ; }
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ using NUnit . Framework ;
2
+ using System ;
3
+ using System . Collections . Generic ;
4
+ using System . Linq ;
5
+ using System . Text ;
6
+ using NHibernate . Linq ;
7
+
8
+ namespace NHibernate . Test . NHSpecificTest . NH3614
9
+ {
10
+ [ TestFixture ]
11
+ public class Fixture : BugTestCase
12
+ {
13
+ [ Test ]
14
+ public void CanProjectListOfStrings ( )
15
+ {
16
+ int id ;
17
+ using ( var s = OpenSession ( ) )
18
+ using ( var tx = s . BeginTransaction ( ) )
19
+ {
20
+ var testEntity = new Entity
21
+ {
22
+ SomeStrings = new List < string > { "Hello" , "World" }
23
+ } ;
24
+ s . Save ( testEntity ) ;
25
+
26
+ tx . Commit ( ) ;
27
+
28
+ id = testEntity . Id ;
29
+ }
30
+
31
+ using ( var s = OpenSession ( ) )
32
+ {
33
+ var result = s . Query < Entity > ( )
34
+ . Where ( x => x . Id == id )
35
+ . Select ( x => x . SomeStrings )
36
+ . ToList ( ) ;
37
+
38
+ Assert . AreEqual ( 1 , result . Count ) ;
39
+
40
+ Assert . AreEqual ( 2 , result . Single ( ) . Count ) ;
41
+ }
42
+
43
+ using ( var s = OpenSession ( ) )
44
+ using ( var tx = s . BeginTransaction ( ) )
45
+ {
46
+ s . Delete ( "from Entity" ) ;
47
+ tx . Commit ( ) ;
48
+ }
49
+ }
50
+ }
51
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <hibernate-mapping xmlns =" urn:nhibernate-mapping-2.2"
3
+ assembly=" NHibernate.Test"
4
+ namespace=" NHibernate.Test.NHSpecificTest.NH3614" >
5
+
6
+ <class name =" Entity" >
7
+ <id name =" Id" >
8
+ <generator class =" native" />
9
+ </id >
10
+
11
+ <bag name =" SomeStrings" table =" SomeStrings" cascade =" all-delete-orphan" >
12
+ <key >
13
+ <column name =" ParentId" />
14
+ </key >
15
+ <element type =" System.String, mscorlib" >
16
+ <column name =" StringValue" />
17
+ </element >
18
+ </bag >
19
+ </class >
20
+
21
+ </hibernate-mapping >
Original file line number Diff line number Diff line change 670
670
<Compile Include =" NHSpecificTest\BagWithLazyExtraAndFilter\Domain.cs" />
671
671
<Compile Include =" NHSpecificTest\BagWithLazyExtraAndFilter\Fixture.cs" />
672
672
<Compile Include =" Component\Basic\ComponentWithUniqueConstraintTests.cs" />
673
+ <Compile Include =" NHSpecificTest\NH3614\Entity.cs" />
674
+ <Compile Include =" NHSpecificTest\NH3614\Fixture.cs" />
673
675
<Compile Include =" NHSpecificTest\NH3505\Student.cs" />
674
676
<Compile Include =" NHSpecificTest\NH3505\Teacher.cs" />
675
677
<Compile Include =" NHSpecificTest\NH3505\Fixture.cs" />
2901
2903
<EmbeddedResource Include =" NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
2902
2904
</ItemGroup >
2903
2905
<ItemGroup >
2906
+ <EmbeddedResource Include =" NHSpecificTest\NH3614\Mappings.hbm.xml" />
2904
2907
<EmbeddedResource Include =" NHSpecificTest\NH3505\Mappings.hbm.xml" />
2905
2908
<EmbeddedResource Include =" NHSpecificTest\NH3428\Mappings.hbm.xml" />
2906
2909
<EmbeddedResource Include =" NHSpecificTest\NH3408\Mappings.hbm.xml" />
@@ -3438,4 +3441,4 @@ if exist hibernate.cfg.xml (del hibernate.cfg.xml)
3438
3441
if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")
3439
3442
copy /y "..\..\..\NHibernate.DomainModel\ABC.hbm.xml" "ABC.hbm.xml"</PostBuildEvent >
3440
3443
</PropertyGroup >
3441
- </Project >
3444
+ </Project >
Original file line number Diff line number Diff line change @@ -217,6 +217,9 @@ private static LambdaExpression MakePredicate(int index)
217
217
218
218
private static Expression GetIdentifier ( ISessionFactory sessionFactory , Expression expression )
219
219
{
220
+ if ( expression . Type . IsPrimitive || expression . Type == typeof ( string ) )
221
+ return expression ;
222
+
220
223
var classMetadata = sessionFactory . GetClassMetadata ( expression . Type ) ;
221
224
if ( classMetadata == null )
222
225
return Expression . Constant ( null ) ;
@@ -257,4 +260,4 @@ private static System.Type GetElementType(System.Type type)
257
260
return elementType ;
258
261
}
259
262
}
260
- }
263
+ }
You can’t perform that action at this time.
0 commit comments