Skip to content

Commit 9fb93f0

Browse files
committed
Creates test for the issue
1 parent 81333f5 commit 9fb93f0

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using NUnit.Framework;
6+
using TestCommon.Model;
7+
using Xtensive.Orm.BulkOperations.Tests.Issues.WrongAliassesIssue;
8+
using Xtensive.Sql;
9+
10+
namespace Xtensive.Orm.BulkOperations.Tests.Issues
11+
{
12+
public class JoinedTableAsSourceForOperationsCauseWrongAliases : AutoBuildTest
13+
{
14+
[Test]
15+
public void CustomerCase()
16+
{
17+
using (var session = Domain.OpenSession())
18+
using (var tx = session.OpenTransaction()) {
19+
var query = session.Query.All<DowntimeReason>()
20+
.Where(r => r.DowntimeInfo.Record.Equipment.Id == 333);
21+
22+
var queryResult = query.Delete();
23+
}
24+
}
25+
26+
[Test]
27+
public void MultipleKeyTest()
28+
{
29+
using (var session = Domain.OpenSession())
30+
using (var tx = session.OpenTransaction()) {
31+
var query = session.Query.All<DowntimeReason2>()
32+
.Where(r => r.DowntimeInfo.Record.Equipment.Id == 333);
33+
34+
var queryResult = query.Delete();
35+
}
36+
}
37+
}
38+
}
39+
40+
namespace Xtensive.Orm.BulkOperations.Tests.Issues.WrongAliassesIssue
41+
{
42+
[HierarchyRoot]
43+
public class DowntimeReason : Entity
44+
{
45+
[Field, Key]
46+
public int Id { get; private set; }
47+
48+
[Field]
49+
public DowntimeInfo DowntimeInfo { get; set; }
50+
}
51+
52+
[HierarchyRoot]
53+
[KeyGenerator(KeyGeneratorKind.None)]
54+
public class DowntimeReason2 : Entity
55+
{
56+
[Field, Key(0)]
57+
public int Id { get; private set; }
58+
59+
[Field, Key(1)]
60+
public int Id2 { get; private set; }
61+
62+
[Field]
63+
public DowntimeInfo DowntimeInfo { get; set; }
64+
}
65+
66+
[HierarchyRoot]
67+
public class DowntimeInfo : Entity
68+
{
69+
[Field, Key]
70+
public int Id { get; private set; }
71+
72+
[Field]
73+
public Record Record { get; set; }
74+
}
75+
76+
[HierarchyRoot]
77+
public class Record : Entity
78+
{
79+
[Field, Key]
80+
public int Id { get; private set; }
81+
82+
[Field]
83+
public Equipment Equipment { get; set; }
84+
}
85+
86+
[HierarchyRoot]
87+
public class Equipment : Entity
88+
{
89+
[Field, Key]
90+
public int Id { get; private set; }
91+
}
92+
}

0 commit comments

Comments
 (0)