2 using System.Collections.Generic;
\r
6 using NUnit.Framework;
\r
7 using Test_NUnit.Linq_101_Samples;
\r
12 namespace Test_NUnit_MySql.Linq_101_Samples
\r
15 namespace Test_NUnit_OracleODP.Linq_101_Samples
\r
17 namespace Test_NUnit_Oracle.Linq_101_Samples
\r
20 namespace Test_NUnit_PostgreSql.Linq_101_Samples
\r
22 namespace Test_NUnit_Sqlite.Linq_101_Samples
\r
24 namespace Test_NUnit_Ingres.Linq_101_Samples
\r
27 namespace Test_NUnit_MsSql_Strict.Linq_101_Samples
\r
29 namespace Test_NUnit_MsSql.Linq_101_Samples
\r
32 namespace Test_NUnit_Firebird
\r
34 #error unknown target
\r
38 public class Inheritance : TestBase
\r
40 [Linq101SamplesModified("Original code did a reference to a newdb nortwhind that didn't exist, currently here uses db instead. Besides Contact type didn't exist")]
\r
41 [Test(Description = "Simple. This sample returns all contacts where the city is London.")]
\r
42 public void LinqToSqlInheritance01()
\r
44 Northwind db = CreateDB();
\r
48 //var cons = from c in db.Contacts
\r
51 //var list = cons.ToList();
\r
52 //Assert.IsTrue(list.Count > 0);
\r
55 [Linq101SamplesModified("Original code did a reference to a newdb nortwhind that didn't exist, currently here uses db instead. Besides Contact type didn't exist")]
\r
56 [Test(Description = "OfType. This sample uses OfType to return all customer contacts.")]
\r
57 public void LinqToSqlInheritance02()
\r
59 Northwind db = CreateDB();
\r
63 //var cons = from c in newDB.Contacts.OfType<CustomerContact>()
\r
66 //var list = cons.ToList();
\r
67 //Assert.IsTrue(list.Count > 0);
\r
71 [Linq101SamplesModified("This test could not be implemented since FullContact is not defined.")]
\r
72 [Test(Description = "CType. This sample uses CType to return FullContact or null.")]
\r
73 public void LinqToSqlInheritance04()
\r
75 Northwind db = CreateDB();
\r
79 //var cons = from c in newDB.Contacts
\r
80 // select (FullContact)c;
\r
82 //var list = cons.ToList();
\r
83 //Assert.IsTrue(list.Count > 0);
\r
86 [Linq101SamplesModified("This test could not be implemented since CustomerContact is not defined.")]
\r
87 [Test(Description = "Cast. This sample uses a cast to retrieve customer contacts who live in London.")]
\r
88 public void LinqToSqlInheritance05()
\r
90 Northwind db = CreateDB();
\r
94 //var cons = from c in newDB.Contacts
\r
95 // where c.ContactType == "Customer" && (CustomerContact)c.City == "London"
\r
98 //var list = cons.ToList();
\r
99 //Assert.IsTrue(list.Count > 0);
\r
104 [Linq101SamplesModified("Original code did a reference to a newdb nortwhind that didn't exist, currently here uses db instead. Besides Contact type didn't exist")]
\r
105 [Test(Description = "UseAsDefault. This sample demonstrates that an unknown contact type will be automatically converted to the default contact type.")]
\r
106 public void LinqToSqlInheritance06()
\r
108 Northwind db = CreateDB();
\r
112 //var contact = new Contact() { ContactType = null, CompanyName = "Unknown Company", City = "London", Phone = "333-444-5555" };
\r
113 //db.Contacts.Add(contact);
\r
114 //db.SubmitChanges();
\r
116 //var con = (from c in db.Contacts
\r
117 // where c.ContactType == null
\r
118 // select c).First();
\r
123 [Linq101SamplesModified("Original code did a reference to a newdb nortwhind that didn't exist, currently here uses db instead. Besides Contact type didn't exist")]
\r
124 [Test(Description = "Insert New Record. This sample demonstrates how to create a new shipper contact.")]
\r
125 public void LinqToSqlInheritance07()
\r
127 Northwind db = CreateDB();
\r
131 //var ShipperContacts = from sc in newDB.Contacts.OfType<ShipperContact>()
\r
132 // where sc.CompanyName = "Northwind Shipper"
\r
136 //var nsc = new ShipperContact() { CompanyName = "Northwind Shipper", Phone = "(123)-456-7890" };
\r
137 //db.Contacts.Add(nsc);
\r
138 //db.SubmitChanges();
\r
141 //ShipperContacts = from sc in db.Contacts.OfType<ShipperContact>()
\r
142 // where sc.CompanyName == "Northwind Shipper"
\r
146 //newDB.Contacts.Remove(nsc);
\r
147 //newDB.SubmitChanges();
\r