Mercurial > pub > bltoolkit
comparison UnitTests/Linq/UserTests/UnnecessaryInnerJoinTest.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f990fcb411a9 |
---|---|
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 } |