comparison UnitTests/Linq/UserTests/SelectManyDeleteTest.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.DataProvider;
6 using BLToolkit.Data.Linq;
7 using BLToolkit.DataAccess;
8 using BLToolkit.Mapping;
9
10 using NUnit.Framework;
11
12 namespace Data.Linq.UserTests
13 {
14 [TestFixture]
15 public class SelectManyDeleteTest : TestBase
16 {
17 [TableName(Name = "GrandChild")]
18 public new class GrandChild
19 {
20 public int ChildID { get; set; }
21 }
22
23 [TableName(Name = "Child")]
24 public new class Child
25 {
26 public int ParentID { get; set; }
27 public int ChildID { get; set; }
28
29 [Association(ThisKey = "ChildID", OtherKey = "ChildID", CanBeNull = false)]
30 public List<GrandChild> GrandChildren { get; set; }
31 }
32
33 [TableName(Name = "Parent")]
34 public new class Parent
35 {
36 [Identity, PrimaryKey(1)]
37 public int ParentID { get; set; }
38
39 [Association(ThisKey = "ParentID", OtherKey = "ParentID", CanBeNull = true)]
40 public List<Child> Children { get; set; }
41 }
42
43 [Test]
44 public void Test([DataContexts(
45 ProviderName.Access, ProviderName.DB2, ProviderName.Informix, "Oracle",
46 ProviderName.PostgreSQL, ProviderName.SqlCe, ProviderName.SQLite, ProviderName.Firebird
47 )] string context)
48 {
49 var harnessIds = new int[2];
50
51 using (var db = GetDataContext(context))
52 {
53 db.GetTable<Parent>()
54 .Where (x => harnessIds.Contains(x.ParentID))
55 .SelectMany(x => x.Children)
56 .SelectMany(x => x.GrandChildren)
57 .Delete();
58 }
59 }
60 }
61 }
62