public void TestMethod4() { var context = new NorthwindDataContext(conn); var city = "London"; var c = context.Customers .Select(x => new { Name = x.ContactName, Phone = x.Phone, Location = new { City = x.City, Country = x.Country } }) .Where(x => x.Location.City == city) .ToList(); }
public void Setup() { db = new NorthwindDataContext(new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindDB"].ConnectionString)); Customers = db.Customers.ToList(); Employees = db.Employees.ToList(); Orders = db.Orders.ToList(); Products = db.Products.ToList(); }
public void TestMethod5() { var context = new NorthwindDataContext(conn); var query = from c in context.Customers where c.Id == "ALFKI" join o in context.Orders on c.Id equals o.CustomerID select new { c.ContactName, o.OrderDate }; query.ToList(); }
public void TestMethod6() { var context = new NorthwindDataContext(conn); var query = from c in context.Customers where c.Id == "ALFKI" from o in context.Orders.Where(o => o.CustomerID == c.Id).DefaultIfEmpty() select new { c.ContactName, o.OrderDate }; query.ToList(); }
public void TestMethod19() { var context = new NorthwindDataContext(conn); var query = context.Orders .OrderByDescending(o => o.Freight * o.Id) .Select(o => new { o.Id, o.CustomerID }) .Select(o => new { id = o.Id, custid = o.CustomerID }); query.ToList(); }
public void TestMethod11() { var context = new NorthwindDataContext(conn); var query = from p in context.Products join s in context.Suppliers on p.Supplier.Id equals s.Id select new { p.ProductName, s.ContactName, s.Phone }; query.ToList(); }
public void TestMethod3() { var context = new NorthwindDataContext(conn); var c = context.Orders.ToList(); }
public void TestMethod2() { var context = new NorthwindDataContext(conn); var c = context.Customers.ToList(); }
public void TestMethod24() { var context = new NorthwindDataContext(conn); var query = from o in context.Orders where o.CustomerID == "SAVEA" orderby o.Id select new { o.Id, o.CustomerID, o.Freight, o.EmployeeID, TotalCount = PartitionedAggregates.Count(), TotalFreight = PartitionedAggregates.Sum(o.Freight), AverageFreightBy = PartitionedAggregates.Average(o.Freight, o.EmployeeID), FirstOrder = PartitionedAggregates.Min(o.OrderDate), LastShipByEmployee = PartitionedAggregates.Max(o.OrderDate, o.EmployeeID), }; var list = query.ToList(); }
public void TestMethod23() { var context = new NorthwindDataContext(conn); var query = from c in context.Customers orderby c.Id select new { c.Id, c.Region, TotalCount = PartitionedAggregates.Count(), CountByStore = PartitionedAggregates.Count(c.Region), RowNumber = PartitionedAggregates.RowNumber(c.Id), Rank = PartitionedAggregates.Rank(c.PostalCode, c.Region), }; var list = query.ToList(); }
public void TestMethod22() { var context = new NorthwindDataContext(conn); var query = context.Orders .Select(o => o.Customer); query.ToList(); }
public void TestMethod10() { var context = new NorthwindDataContext(conn); var query = from c in context.Customers let x = "Test" let y = c.Phone where c.Id == "ALFKI" select new { x, y, c.PostalCode, c }; query.ToList(); }
public void TestMethod18() { var context = new NorthwindDataContext(conn); var query = context .Orders .OrderBy(o => o.Customer.ContactName) .ThenBy(o => o.Employee.LastName) .Select(o => new { o.Id, o.Customer.ContactName, o.Employee.LastName }); query.ToList(); }
public void TestMethod15() { var context = new NorthwindDataContext(conn); var query = from c in context.Customers.OrderBy(c => c.ContactName) from o in context.Orders.OrderBy(o => o.OrderDate) where c.Id == o.CustomerID select new { c.ContactName, o.OrderDate }; var list = query.ToList(); var resorted = list.OrderBy(x => x.ContactName).ThenBy(x => x.OrderDate).ToList(); Assert.IsTrue(list.SequenceEqual(resorted)); }
public void TestMethod14() { var context = new NorthwindDataContext(conn); var query = ( from o in context.Orders from d in o.OrderDetails.Take(o.Id) select new { order = o, details = d, }).Take(5); var list = query.ToList(); Assert.IsTrue(list.Count <= 5); }
public void TestMethod13() { var context = new NorthwindDataContext(conn); var query = context.Orders.Take(3); var list = query.ToList(); Assert.IsTrue(list.Count <= 3); }
public void TestMethod12() { var context = new NorthwindDataContext(conn); var query = from o in context.Orders select new { o.Freight, AwayFromZero = Math.Round(o.Freight, 1, MidpointRounding.AwayFromZero), ToEven = Math.Round(o.Freight, 1, MidpointRounding.ToEven) }; query.ToList(); }
public void TestMethod20() { var context = new NorthwindDataContext(conn); var query = context.Orders .OrderBy(o => new { o.Customer.ContactName, x = new { o.Customer, o } }) .Select(o => new { id = o.Id, custid = o.CustomerID }); query.ToList(); }
public void TestMethod9() { var context = new NorthwindDataContext(conn); var query = from o in context.Orders where o.Customer.Id == "ALFKI" select new { o.Customer.ContactName, o.OrderDate }; query.ToList(); }