public static void Execute() { var stopWatch = new Stopwatch(); stopWatch.Start(); DataConnection.DefaultSettings = new MySettings(); using var db = new AdventureWorks2017DB(); var query = from a in db.Addresss group a by a.City into addressGroup select new { City = addressGroup.Key, Count = addressGroup.Count() }; foreach (var queryObject in query) { Console.WriteLine("{0} {1}", queryObject.Count, queryObject.City); } stopWatch.Stop(); // Get the elapsed time as a TimeSpan value. var ts = stopWatch.Elapsed; // Format and display the TimeSpan value. var elapsedTime = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds:00}"; //; is for my shell script, which outputs to a csv Console.WriteLine("RunTime " + elapsedTime + ";"); }
public static void Execute() { var stopWatch = new Stopwatch(); stopWatch.Start(); DataConnection.DefaultSettings = new MySettings(); var db = new AdventureWorks2017DB(); var query = from p in db.Products from pv in db.ProductVendors where p.ProductID == pv.ProductID && pv.MinOrderQty > 5 select p; foreach (var product in query) { Console.WriteLine(product.Name); } stopWatch.Stop(); // Get the elapsed time as a TimeSpan value. var ts = stopWatch.Elapsed; // Format and display the TimeSpan value. var elapsedTime = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds:00}"; //; is for my shell script, which outputs to a csv Console.WriteLine("RunTime " + elapsedTime + ";"); }
public static void Execute() { var stopWatch = new Stopwatch(); stopWatch.Start(); DataConnection.DefaultSettings = new MySettings(); using var db = new AdventureWorks2017DB(); var query = from p in db.Products where p.SellStartDate > new DateTime(2007, 1, 1) && p.ProductNumber.StartsWith("FW") select p.Name; foreach (var product in query) { Console.WriteLine(product); } stopWatch.Stop(); // Get the elapsed time as a TimeSpan value. var ts = stopWatch.Elapsed; // Format and display the TimeSpan value. var elapsedTime = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds:00}"; //; is for my shell script, which outputs to a csv Console.WriteLine("RunTime " + elapsedTime + ";"); }
public static void Execute() { var stopWatch = new Stopwatch(); stopWatch.Start(); DataConnection.DefaultSettings = new MySettings(); using var db = new AdventureWorks2017DB(); var query = from pi in db.ProductInventorys orderby pi.Shelf select pi; foreach (var pi in query) { Console.WriteLine(pi.Shelf); } stopWatch.Stop(); // Get the elapsed time as a TimeSpan value. var ts = stopWatch.Elapsed; // Format and display the TimeSpan value. var elapsedTime = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds:00}"; //; is for my shell script, which outputs to a csv Console.WriteLine("RunTime " + elapsedTime + ";"); }
public static void Execute() { var stopWatch = new Stopwatch(); stopWatch.Start(); DataConnection.DefaultSettings = new MySettings(); using var db = new AdventureWorks2017DB(); var query = from ba in db.BusinessEntityAddresss join a in db.Addresss on ba.AddressID equals a.AddressID join sp in db.StateProvinces on a.StateProvinceID equals sp.StateProvinceID join cr in db.CountryRegions on sp.CountryRegionCode equals cr.CountryRegionCode join st in db.SalesTerritorys on sp.TerritoryID equals st.TerritoryID select new { ba, a, sp, cr, st }; foreach (var queryObject in query) { //Print first three columns Console.WriteLine("{0} {1} {2}", queryObject.ba.BusinessEntityID, queryObject.ba.AddressID, queryObject.ba.AddressTypeID); } stopWatch.Stop(); // Get the elapsed time as a TimeSpan value. var ts = stopWatch.Elapsed; // Format and display the TimeSpan value. var elapsedTime = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds:00}"; //; is for my shell script, which outputs to a csv Console.WriteLine("RunTime " + elapsedTime + ";"); }