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 +51
-0
lines changed
tests/ServiceStack.OrmLite.Tests Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System . Collections . Generic ;
2
+ using NUnit . Framework ;
3
+ using ServiceStack . DataAnnotations ;
4
+ using ServiceStack . Text ;
5
+
6
+ namespace ServiceStack . OrmLite . Tests . Issues
7
+ {
8
+ public class Root
9
+ {
10
+ [ PrimaryKey ]
11
+ public int RootId { get ; set ; }
12
+
13
+ [ Reference ]
14
+ public List < RootItem > Items { get ; set ; }
15
+ }
16
+
17
+ public class RootItem
18
+ {
19
+ [ PrimaryKey ]
20
+ public int RootItemId { get ; set ; }
21
+
22
+ public int RootId { get ; set ; } //`{Parent}Id` convention to refer to Client
23
+
24
+ public string MyValue { get ; set ; }
25
+ }
26
+
27
+ public class LoadReferencesForeignKeyTests : OrmLiteTestBase
28
+ {
29
+ [ Test ]
30
+ public void Does_populate_Ref_Ids_of_non_convention_PrimaryKey_Tables ( )
31
+ {
32
+ using ( var db = OpenDbConnection ( ) )
33
+ {
34
+ db . DropAndCreateTable < Root > ( ) ;
35
+ db . DropAndCreateTable < RootItem > ( ) ;
36
+
37
+ var root = new Root {
38
+ RootId = 1 ,
39
+ Items = new List < RootItem > {
40
+ new RootItem { RootItemId = 2 , MyValue = "x" }
41
+ }
42
+ } ;
43
+
44
+ db . Save ( root , references : true ) ;
45
+
46
+ Assert . That ( root . Items [ 0 ] . RootId , Is . EqualTo ( root . RootId ) ) ;
47
+ }
48
+ }
49
+ }
50
+ }
Original file line number Diff line number Diff line change 141
141
<Compile Include =" Issues\CsvTests.cs" />
142
142
<Compile Include =" Issues\CustomFieldTests.cs" />
143
143
<Compile Include =" Issues\LoadReferencesCaseSensitiveTest.cs" />
144
+ <Compile Include =" Issues\LoadReferencesForeignKeyTests.cs" />
144
145
<Compile Include =" Issues\LoadSelectIssue.cs" />
145
146
<Compile Include =" Issues\MultipleSelfJoinsWithNullableInts.cs" />
146
147
<Compile Include =" Issues\SelectScalarTests.cs" />
You can’t perform that action at this time.
0 commit comments