PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/web/mcs/class/System.Data.Linq/src/DbLinq/Test/Providers/Linq_101_Samples/ExsistIn_Any_All.cs

https://bitbucket.org/steenlund/mono-2.6.7-for-amiga
C# | 74 lines | 62 code | 11 blank | 1 comment | 4 complexity | f0385456ef676f0bfbe8367f3a8f4ed0 MD5 | raw file
Possible License(s): LGPL-2.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, GPL-2.0, LGPL-2.1
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Test_NUnit;
  6. using NUnit.Framework;
  7. using Test_NUnit.Linq_101_Samples;
  8. using nwind;
  9. // test ns Linq_101_Samples
  10. #if MYSQL
  11. namespace Test_NUnit_MySql.Linq_101_Samples
  12. #elif ORACLE && ODP
  13. namespace Test_NUnit_OracleODP.Linq_101_Samples
  14. #elif ORACLE
  15. namespace Test_NUnit_Oracle.Linq_101_Samples
  16. #elif POSTGRES
  17. namespace Test_NUnit_PostgreSql.Linq_101_Samples
  18. #elif SQLITE
  19. namespace Test_NUnit_Sqlite.Linq_101_Samples
  20. #elif INGRES
  21. namespace Test_NUnit_Ingres.Linq_101_Samples
  22. #elif MSSQL && L2SQL
  23. namespace Test_NUnit_MsSql_Strict.Linq_101_Samples
  24. #elif MSSQL
  25. namespace Test_NUnit_MsSql.Linq_101_Samples
  26. #elif FIREBIRD
  27. namespace Test_NUnit_Firebird.Linq_101_Samples
  28. #endif
  29. {
  30. [TestFixture]
  31. public class ExsistIn_Any_All : TestBase
  32. {
  33. [Test(Description = "Any - Simple. This sample uses Any to return only Customers that have no Orders.")]
  34. public void LinqToSqlExists01()
  35. {
  36. Northwind db = CreateDB();
  37. var q = from c in db.Customers
  38. where !c.Orders.Any()
  39. select c;
  40. var list = q.ToList();
  41. Assert.IsTrue(list.Count > 0);
  42. }
  43. [Linq101SamplesModified("Strange casting, It seems like original northwind discontinued were boolean")]
  44. [Test(Description = "Any - Conditional. This sample uses Any to return only Categories that have at least one Discontinued product.")]
  45. public void LinqToSqlExists02()
  46. {
  47. Northwind db = CreateDB();
  48. var q = from o in db.Orders where o.OrderDetails.Any(od => od.Order.Customer.Country == "France") select o;
  49. var list = q.ToList();
  50. Assert.IsTrue(list.Count > 0);
  51. }
  52. [Test(Description = "All - Conditional. This sample uses All to return Customers whom all of their orders have been shipped to their own city or whom have no orders.")]
  53. public void LinqToSqlExists03()
  54. {
  55. Northwind db = CreateDB();
  56. var q = from c in db.Customers
  57. where c.Orders.All(o => o.ShipCity == c.City)
  58. select c;
  59. var list = q.ToList();
  60. Assert.IsTrue(list.Count > 0);
  61. }
  62. }
  63. }