0
|
1 using System;
|
|
2 using System.Collections.Generic;
|
|
3 using System.Linq;
|
|
4
|
|
5 using BLToolkit.Data;
|
|
6 using BLToolkit.DataAccess;
|
|
7 using BLToolkit.Mapping;
|
|
8
|
|
9 using NUnit.Framework;
|
|
10
|
|
11 namespace Data.Linq.UserTests
|
|
12 {
|
|
13 [TestFixture]
|
|
14 public class UnnecessaryInnerJoinTest : TestBase
|
|
15 {
|
|
16 class Table1
|
|
17 {
|
|
18 [PrimaryKey(1)]
|
|
19 [Identity]
|
|
20 public Int64 Field1 { get; set; }
|
|
21 public Int64 Field2 { get; set; }
|
|
22 }
|
|
23
|
|
24 class Table2
|
|
25 {
|
|
26 [PrimaryKey(1)]
|
|
27 [Identity]
|
|
28 public Int64 Field2 { get; set; }
|
|
29
|
|
30 [Association(ThisKey = "Field2", OtherKey = "Field2", CanBeNull = false)]
|
|
31 public List<Table1> Field3 { get; set; }
|
|
32 }
|
|
33
|
|
34 [Test]
|
|
35 public void Test([DataContextsAttribute(ExcludeLinqService=true)] string context)
|
|
36 {
|
|
37 var ids = new long[] { 1, 2, 3 };
|
|
38
|
|
39 using (var db = new DbManager(context))
|
|
40 {
|
|
41 var q =
|
|
42 from t1 in db.GetTable<Table2>()
|
|
43 where t1.Field3.Any(x => ids.Contains(x.Field1))
|
|
44 select new { t1.Field2 };
|
|
45
|
|
46 var sql = q.ToString();
|
|
47
|
|
48 Assert.That(sql.IndexOf("INNER JOIN"), Is.LessThan(0));
|
|
49 }
|
|
50 }
|
|
51 }
|
|
52 }
|