This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +79
-0
lines changed
tests/ServiceStack.OrmLite.Tests Expand file tree Collapse file tree 2 files changed +79
-0
lines changed Original file line number Diff line number Diff line change
1
+ using NUnit . Framework ;
2
+ using ServiceStack . DataAnnotations ;
3
+ using ServiceStack . Text ;
4
+
5
+ namespace ServiceStack . OrmLite . Tests . Issues
6
+ {
7
+ [ TestFixture ]
8
+ public class LoadSelectIssue : OrmLiteTestBase
9
+ {
10
+ [ Test ]
11
+ public void Can_LoadSelect_PlayerEquipment ( )
12
+ {
13
+ using ( var db = OpenDbConnection ( ) )
14
+ {
15
+ db . DropTable < PlayerEquipment > ( ) ;
16
+ db . DropTable < ItemData > ( ) ;
17
+
18
+ db . CreateTable < ItemData > ( ) ;
19
+ db . CreateTable < PlayerEquipment > ( ) ;
20
+
21
+ var item1 = new ItemData { Data = "ITEM1" } ;
22
+ db . Save ( item1 ) ;
23
+
24
+ db . Save ( new PlayerEquipment
25
+ {
26
+ PlayerId = 1 ,
27
+ ItemId = item1 . Id ,
28
+ Quantity = 1 ,
29
+ IsEquipped = true ,
30
+ } ) ;
31
+
32
+ var item2 = new ItemData { Data = "ITEM2" } ;
33
+ db . Save ( item2 ) ;
34
+
35
+ db . Save ( new PlayerEquipment
36
+ {
37
+ PlayerId = 1 ,
38
+ ItemId = item2 . Id ,
39
+ Quantity = 1 ,
40
+ IsEquipped = false ,
41
+ } ) ;
42
+
43
+ var playerId = 1 ;
44
+ var results = db . LoadSelect < PlayerEquipment > ( q => q . PlayerId == playerId ) ;
45
+
46
+ results . PrintDump ( ) ;
47
+ }
48
+ }
49
+ }
50
+
51
+ public class PlayerEquipment
52
+ {
53
+ public string Id
54
+ {
55
+ get { return PlayerId + "/" + ItemId ; }
56
+ }
57
+
58
+ public int PlayerId { get ; set ; }
59
+
60
+ [ References ( typeof ( ItemData ) ) ]
61
+ public int ItemId { get ; set ; }
62
+
63
+ public int Quantity { get ; set ; }
64
+
65
+ public bool IsEquipped { get ; set ; }
66
+
67
+ [ Reference ]
68
+ public ItemData ItemData { get ; set ; }
69
+ }
70
+
71
+ public class ItemData
72
+ {
73
+ [ AutoIncrement ]
74
+ public int Id { get ; set ; }
75
+
76
+ public string Data { get ; set ; }
77
+ }
78
+ }
Original file line number Diff line number Diff line change 130
130
<Compile Include =" Expression\SelectExpressionTests.cs" />
131
131
<Compile Include =" Issues\ComplexJoinWithAlias.cs" />
132
132
<Compile Include =" Issues\CustomFieldTests.cs" />
133
+ <Compile Include =" Issues\LoadSelectIssue.cs" />
133
134
<Compile Include =" Issues\UtcDateTimeIssueTests.cs" />
134
135
<Compile Include =" Issues\JoinsWithSchemas.cs" />
135
136
<Compile Include =" Issues\MappingFieldsFromStoredProcedureTests.cs" />
You can’t perform that action at this time.
0 commit comments