static void PerformanceUpdateRawTest(Int32 numberOfInserts, Boolean proxiesEnabled, Boolean lazyEnabled) { DateTime started = DateTime.Now; Int32 loopymax = numberOfInserts; TheoreticalEntities context = new TheoreticalEntities(); context.Configuration.ProxyCreationEnabled = proxiesEnabled; context.Configuration.LazyLoadingEnabled = lazyEnabled; var updateTarget = context.OrderEntity .Include(a => a.OrderItem) .Include(a => a.OrderInformation) .First(); for (Int32 i = 0; i < loopymax; i++) { updateTarget.OptionalNote = "Giggidy" + i.ToString(); if (i % 2 == 0) { var infoitem = context.OrderInformationEntity.CreateAndAdd(); infoitem.TrackAmount = Convert.ToDecimal(i) * 100; infoitem.TrackDate = DateTime.Now; infoitem.TrackingNumber = "tracky" + i.ToString(); updateTarget.OrderInformation.Add(infoitem); } else { var minDate = updateTarget.OrderInformation .Where(a=>a.OrderInformationId >0).Min(a => a.OrderInformationId); context.OrderInformationEntity.Remove(updateTarget.OrderInformation .Where(a => a.OrderInformationId == minDate).First()); //updateTarget.OrderInformation.Remove(); } context.SaveChanges(); } Console.WriteLine("Performance update raw time to complete:" + DateTime.Now.Subtract(started).TotalSeconds.ToString()); }
static void PerformanceAddRawTest(Int32 numberOfInserts, Boolean proxiesEnabled, Boolean lazyEnabled) { DateTime started = DateTime.Now; Int32 loopymax = numberOfInserts; TheoreticalEntities context = new TheoreticalEntities(); context.Configuration.ProxyCreationEnabled = proxiesEnabled; context.Configuration.LazyLoadingEnabled = lazyEnabled; for (Int32 i = 0; i < loopymax; i++) { var orderEntity = context.OrderEntity.CreateAndAdd(); orderEntity.Number = "4000" + Guid.NewGuid().ToString(); orderEntity.OrderDate = DateTime.Now; orderEntity.Status = (Int32)StatusEnum.Giggidy; orderEntity.TaxRate = (34.23m); orderEntity.ConcurrencyId = 0; orderEntity.OptionalNote = null; orderEntity.OptionalPrice = 123M; orderEntity.OrderItem = new List<OrderItemEntity>() { new OrderItemEntity() { ConcurrencyId = 0, HasSerialNumber = false, SalePrice = 34.12M, SerialNumber = "", Upc = "MYUPC" }, new OrderItemEntity() { ConcurrencyId = 0, HasSerialNumber = true, SalePrice = 134.12M, SerialNumber = "ASerialnumber", Upc = "OHTERUPC" } }; orderEntity.OrderInformation = new List<OrderInformationEntity>() { new OrderInformationEntity() { TrackAmount = 100, TrackDate = DateTime.Now, TrackingNumber = "TRK100500" }, new OrderInformationEntity() { TrackAmount = null, TrackDate = null, TrackingNumber = null } }; context.SaveChanges(); } Console.WriteLine("Performance add raw time to complete:" + DateTime.Now.Subtract(started).TotalSeconds.ToString()); }
static void PerformanceUpdate() { var context = new TheoreticalEntities(); context.OrderEntity.RemoveAll(context.OrderEntity.ToArray()); context.SaveChanges(); PerformanceAddMapperTest(1, false, false); PerformanceUpdateMapperTest(500, true, false); context = new TheoreticalEntities(); context.OrderEntity.RemoveAll(context.OrderEntity.ToArray()); context.SaveChanges(); PerformanceAddMapperTest(1, false, false); PerformanceUpdateRawTest(500, true, false); }
static void Main(string[] args) { try { TheoreticalEntities context = new TheoreticalEntities(); context.OrderEntity.RemoveAll(context.OrderEntity.ToArray()); context.SaveChanges(); //this uses straight up mapping DataMapBlock(); //the thingie //SimpleThingy(); //this shows how you can rename things //DataMapBlockOdd(); //TypeMapper(); //TestTwo(); } catch (Exception ex) { //expect this... Console.WriteLine(ex.ToString()); } Console.WriteLine("Press any key to exit"); Console.ReadKey(); }