2 using System.Collections.Generic;
\r
6 using NUnit.Framework;
\r
7 using Test_NUnit.Linq_101_Samples;
\r
11 // test ns Linq_101_Samples
\r
13 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
19 namespace Test_NUnit_PostgreSql.Linq_101_Samples
\r
21 namespace Test_NUnit_Sqlite.Linq_101_Samples
\r
23 namespace Test_NUnit_Ingres.Linq_101_Samples
\r
24 #elif MSSQL && MONO_STRICT
\r
25 namespace Test_NUnit_MsSql_Strict.Linq_101_Samples
\r
27 namespace Test_NUnit_MsSql.Linq_101_Samples
\r
29 namespace Test_NUnit_Firebird.Linq_101_Samples
\r
33 public class Inheritance : TestBase
\r
35 [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
36 [Test(Description = "Simple. This sample returns all contacts where the city is London.")]
\r
37 public void LinqToSqlInheritance01()
\r
39 Northwind db = CreateDB();
\r
43 //var cons = from c in db.Contacts
\r
46 //var list = cons.ToList();
\r
47 //Assert.IsTrue(list.Count > 0);
\r
50 [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
51 [Test(Description = "OfType. This sample uses OfType to return all customer contacts.")]
\r
52 public void LinqToSqlInheritance02()
\r
54 Northwind db = CreateDB();
\r
58 //var cons = from c in newDB.Contacts.OfType<CustomerContact>()
\r
61 //var list = cons.ToList();
\r
62 //Assert.IsTrue(list.Count > 0);
\r
66 [Linq101SamplesModified("This test could not be implemented since FullContact is not defined.")]
\r
67 [Test(Description = "CType. This sample uses CType to return FullContact or null.")]
\r
68 public void LinqToSqlInheritance04()
\r
70 Northwind db = CreateDB();
\r
74 //var cons = from c in newDB.Contacts
\r
75 // select (FullContact)c;
\r
77 //var list = cons.ToList();
\r
78 //Assert.IsTrue(list.Count > 0);
\r
81 [Linq101SamplesModified("This test could not be implemented since CustomerContact is not defined.")]
\r
82 [Test(Description = "Cast. This sample uses a cast to retrieve customer contacts who live in London.")]
\r
83 public void LinqToSqlInheritance05()
\r
85 Northwind db = CreateDB();
\r
89 //var cons = from c in newDB.Contacts
\r
90 // where c.ContactType == "Customer" && (CustomerContact)c.City == "London"
\r
93 //var list = cons.ToList();
\r
94 //Assert.IsTrue(list.Count > 0);
\r
99 [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
100 [Test(Description = "UseAsDefault. This sample demonstrates that an unknown contact type will be automatically converted to the default contact type.")]
\r
101 public void LinqToSqlInheritance06()
\r
103 Northwind db = CreateDB();
\r
107 //var contact = new Contact() { ContactType = null, CompanyName = "Unknown Company", City = "London", Phone = "333-444-5555" };
\r
108 //db.Contacts.Add(contact);
\r
109 //db.SubmitChanges();
\r
111 //var con = (from c in db.Contacts
\r
112 // where c.ContactType == null
\r
113 // select c).First();
\r
118 [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
119 [Test(Description = "Insert New Record. This sample demonstrates how to create a new shipper contact.")]
\r
120 public void LinqToSqlInheritance07()
\r
122 Northwind db = CreateDB();
\r
126 //var ShipperContacts = from sc in newDB.Contacts.OfType<ShipperContact>()
\r
127 // where sc.CompanyName = "Northwind Shipper"
\r
131 //var nsc = new ShipperContact() { CompanyName = "Northwind Shipper", Phone = "(123)-456-7890" };
\r
132 //db.Contacts.Add(nsc);
\r
133 //db.SubmitChanges();
\r
136 //ShipperContacts = from sc in db.Contacts.OfType<ShipperContact>()
\r
137 // where sc.CompanyName == "Northwind Shipper"
\r
141 //newDB.Contacts.Remove(nsc);
\r
142 //newDB.SubmitChanges();
\r