File tree Expand file tree Collapse file tree 4 files changed +106
-0
lines changed Expand file tree Collapse file tree 4 files changed +106
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Linq ;
3
+ using System . Linq . Dynamic ;
4
+ using NHibernate . Linq ;
5
+ using NUnit . Framework ;
6
+
7
+ namespace NHibernate . Test . NHSpecificTest . NH3818
8
+ {
9
+ [ TestFixture ]
10
+ public class Fixture : BugTestCase
11
+ {
12
+ public override string BugNumber
13
+ {
14
+ get { return "NH3818" ; }
15
+ }
16
+
17
+ [ Test ]
18
+ public void SelectConditionalValuesTest ( )
19
+ {
20
+ using ( var spy = new SqlLogSpy ( ) )
21
+ using ( var session = OpenSession ( ) )
22
+ using ( session . BeginTransaction ( ) )
23
+ {
24
+ var days = 33 ;
25
+
26
+ var cat = new MyLovelyCat
27
+ {
28
+ GUID = Guid . NewGuid ( ) ,
29
+ Birthdate = DateTime . Now . AddDays ( - days ) ,
30
+ Color = "Black" ,
31
+ Name = "Kitty" ,
32
+ Price = 0
33
+ } ;
34
+ session . Save ( cat ) ;
35
+
36
+ session . Flush ( ) ;
37
+
38
+ var catInfo =
39
+ session . Query < MyLovelyCat > ( )
40
+ . Select ( o => new
41
+ {
42
+ o . Color ,
43
+ AliveDays = ( int ) ( DateTime . Now - o . Birthdate ) . TotalDays ,
44
+ o . Name ,
45
+ o . Price ,
46
+ } )
47
+ . Single ( ) ;
48
+
49
+ //Console.WriteLine(spy.ToString());
50
+ Assert . That ( catInfo . AliveDays == days ) ;
51
+
52
+ var catInfo2 =
53
+ session . Query < MyLovelyCat > ( )
54
+ . Select ( o => new
55
+ {
56
+ o . Color ,
57
+ AliveDays = o . Price > 0 ? ( DateTime . Now - o . Birthdate ) . TotalDays : 0 ,
58
+ o . Name ,
59
+ o . Price ,
60
+ } )
61
+ . Single ( ) ;
62
+
63
+ //Console.WriteLine(spy.ToString());
64
+ Assert . That ( catInfo2 . AliveDays == 0 ) ;
65
+
66
+ }
67
+ }
68
+
69
+ }
70
+ }
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.NH3818"
5
+ default-lazy=" false"
6
+ default-access =" property" >
7
+
8
+ <class name =" MyLovelyCat" table =" MyLovelyCat" >
9
+ <id column =" GUID" name =" GUID" ></id >
10
+ <property column =" Name" name =" Name" not-null =" true" />
11
+ <property column =" Color" name =" Color" not-null =" true" />
12
+ <property column =" Birthdate" name =" Birthdate" not-null =" true" />
13
+ <property column =" Price" name =" Price" not-null =" true" />
14
+ </class >
15
+
16
+ </hibernate-mapping >
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 . NH3818
7
+ {
8
+ class MyLovelyCat
9
+ {
10
+ public virtual Guid GUID { get ; set ; }
11
+
12
+ public virtual String Name { get ; set ; }
13
+ public virtual String Color { get ; set ; }
14
+ public virtual DateTime Birthdate { get ; set ; }
15
+ public virtual Decimal Price { get ; set ; }
16
+ }
17
+ }
Original file line number Diff line number Diff line change 872
872
<Compile Include =" NHSpecificTest\NH3727\Entity.cs" />
873
873
<Compile Include =" NHSpecificTest\NH3727\FixtureByCode.cs" />
874
874
<Compile Include =" NHSpecificTest\NH3795\Fixture.cs" />
875
+ <Compile Include =" NHSpecificTest\NH3818\Fixture.cs" />
876
+ <Compile Include =" NHSpecificTest\NH3818\MyLovelyCat.cs" />
875
877
<Compile Include =" NHSpecificTest\NH646\Domain.cs" />
876
878
<Compile Include =" NHSpecificTest\NH646\Fixture.cs" />
877
879
<Compile Include =" NHSpecificTest\NH3234\Fixture.cs" />
3145
3147
<EmbeddedResource Include =" NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
3146
3148
</ItemGroup >
3147
3149
<ItemGroup >
3150
+ <EmbeddedResource Include =" NHSpecificTest\NH3818\Mappings.hbm.xml" />
3148
3151
<EmbeddedResource Include =" NHSpecificTest\NH3666\Mappings.hbm.xml" >
3149
3152
<SubType >Designer</SubType >
3150
3153
</EmbeddedResource >
You can’t perform that action at this time.
0 commit comments