예제 #1
0
		private static void FetchSalesOrderHeaderEFIndividually()
		{
			Console.WriteLine("Fetching entities individually, EF6.0.1");
			var headers = FetchSalesOrderHeaderEF();
			int count = 0;
			var sw = new Stopwatch();
			sw.Start();
			foreach(var fetched in headers)
			{
				using(var ctx = new AWDataContext())
				{
					var toFetch = ctx.SalesOrderHeaders.Single(soh => soh.SalesOrderId == fetched.SalesOrderId);
					count++;
				}
				if(count > 1000)
				{
					break;
				}
			}
			sw.Stop();
			double average = (double)sw.ElapsedMilliseconds / (double)count;
			Console.WriteLine("Fetching {0} entities individually through CTor/PK fetch took {1}ms, or {2}ms/entity", count, sw.ElapsedMilliseconds, average);
		}
예제 #2
0
		private static List<EF6.Bencher.EntityClasses.SalesOrderHeader> FetchSalesOrderHeaderEFNoTracking()
		{
			var frameworkName = CreateFrameworkName("Entity Framework v{0} (v{1}), using AsNoTracking()", typeof(System.Data.Entity.DbContext));
			var sw = new Stopwatch();
			sw.Start();
			List<EF6.Bencher.EntityClasses.SalesOrderHeader> headers = null;
			using(var ctx = new AWDataContext())
			{
				headers = ctx.SalesOrderHeaders.AsNoTracking().ToList();
			}
			sw.Stop();
			ReportResult(frameworkName, sw.ElapsedMilliseconds, headers.Count);
			foreach(var e in headers)
			{
				if(e.SalesOrderId <= 0)
				{
					Console.WriteLine("EF: Data is empty");
					break;
				}
			}
			return headers;
		}