1
+ using System . Runtime . Serialization ;
2
+ using NUnit . Framework ;
3
+ using ServiceStack . DataAnnotations ;
4
+ using ServiceStack . Text ;
5
+
6
+ namespace ServiceStack . OrmLite . Tests . Issues
7
+ {
8
+ [ Alias ( "makemodel" ) ]
9
+ public class MakeModel
10
+ {
11
+ [ Alias ( "id" ) , PrimaryKey ]
12
+ public int Id { get ; set ; }
13
+
14
+ [ Alias ( "manufacturer" ) ]
15
+ public string Manufacturer { get ; set ; }
16
+
17
+ [ Alias ( "model" ) ]
18
+ public string Model { get ; set ; }
19
+
20
+ [ References ( typeof ( PerformanceCategory ) ) ]
21
+ [ Alias ( "performance_category_id" ) ]
22
+ public int PerformanceCategoryId { get ; set ; }
23
+
24
+ public ulong RowVersion { get ; set ; }
25
+ }
26
+
27
+ [ Alias ( "performance_category" ) ]
28
+ public class PerformanceCategory
29
+ {
30
+ [ Alias ( "id" ) , PrimaryKey ]
31
+ public int Id { get ; set ; }
32
+
33
+ [ Alias ( "category" ) ]
34
+ public string Category { get ; set ; }
35
+
36
+ [ Alias ( "description" ) ]
37
+ public string Description { get ; set ; }
38
+ }
39
+
40
+ [ DataContract ]
41
+ public class VehicleDto : DataTransferObject
42
+ {
43
+ [ DataMember ( Name = "id" ) ]
44
+ public string Id { get ; set ; }
45
+
46
+ [ DataMember ( Name = "manufacturer" ) ]
47
+ public string Manufacturer { get ; set ; }
48
+
49
+ [ DataMember ( Name = "model" ) ]
50
+ public string Model { get ; set ; }
51
+
52
+ [ DataMember ( Name = "performance_category_id" ) ]
53
+ public string PerformanceCategoryId { get ; set ; }
54
+
55
+ [ DataMember ( Name = "category" ) ]
56
+ public string Category { get ; set ; }
57
+
58
+ [ DataMember ( Name = "row-version" ) ]
59
+ public ulong RowVersion { get ; set ; }
60
+ }
61
+
62
+ public class DataTransferObject { }
63
+
64
+ public class RowVersionJoinIssue : OrmLiteTestBase
65
+ {
66
+ [ Test ]
67
+ public void Can_join_on_table_with_RowVersion ( )
68
+ {
69
+ using ( var db = OpenDbConnection ( ) )
70
+ {
71
+ var id = 1 ;
72
+
73
+ db . DropTable < MakeModel > ( ) ;
74
+ db . DropTable < PerformanceCategory > ( ) ;
75
+ db . CreateTable < PerformanceCategory > ( ) ;
76
+ db . CreateTable < MakeModel > ( ) ;
77
+
78
+ db . Insert ( new PerformanceCategory { Id = 1 , Category = "category" } ) ;
79
+ db . Insert ( new MakeModel { Id = 1 , Manufacturer = "manufacturer" , Model = "model" , PerformanceCategoryId = 1 } ) ;
80
+
81
+ var row = db . Single < VehicleDto > ( db . From < MakeModel , PerformanceCategory > ( ) . Where ( v => v . Id == id ) ) ;
82
+
83
+ db . GetLastSql ( ) . Print ( ) ;
84
+
85
+ Assert . That ( row . Id , Is . EqualTo ( "1" ) ) ;
86
+ Assert . That ( row . Category , Is . EqualTo ( "category" ) ) ;
87
+ }
88
+ }
89
+
90
+ }
91
+ }
0 commit comments