Exemplo n.º 1
0
        static void PerformanceAddMapperTest(Int32 numberOfInserts, Boolean proxiesEnabled, Boolean lazyEnabled)
        {
            DateTime started = DateTime.Now;
            Int32 loopymax = numberOfInserts;
            EntityFrameworkRepositoryContext<TheoreticalEntities> context = new EntityFrameworkRepositoryContext<TheoreticalEntities>();
            OrderPocoDataMapBlock blocky = new OrderPocoDataMapBlock();
            blocky.Context = context;

            context.DbContext.Configuration.ProxyCreationEnabled = proxiesEnabled;
            context.DbContext.Configuration.LazyLoadingEnabled = lazyEnabled;

            for (Int32 i = 0; i < loopymax; i++)
            {
                var newPoco = CreateNewOrderPoco();

                blocky.Add(newPoco);

                context.SaveChanges();
            }

            Console.WriteLine("Performance add datamapper time to complete:" + DateTime.Now.Subtract(started).TotalSeconds.ToString());
        }
Exemplo n.º 2
0
        static void PerformanceUpdateMapperTest(Int32 numberOfInserts, Boolean proxiesEnabled, Boolean lazyEnabled)
        {
            DateTime started = DateTime.Now;
            Int32 loopymax = numberOfInserts;
            EntityFrameworkRepositoryContext<TheoreticalEntities> context = new EntityFrameworkRepositoryContext<TheoreticalEntities>();
            OrderPocoDataMapBlock blocky = new OrderPocoDataMapBlock();
            blocky.Context = context;

            context.DbContext.Configuration.ProxyCreationEnabled = proxiesEnabled;
            context.DbContext.Configuration.LazyLoadingEnabled = lazyEnabled;

            var updateTarget = blocky.FindFirst();

            for (Int32 i = 0; i < loopymax; i++)
            {
                updateTarget.OptionalNote = "Giggidy" + i.ToString();

                if (i % 2 == 0)
                {
                    updateTarget.OrderInformation.Add(new OrderInformationPoco()
                    {
                        TrackAmount = Convert.ToDecimal(i) * 100,
                        TrackDate = DateTime.Now,
                        TrackingNumber = "tracky" + i.ToString()
                    });
                }
                else
                {
                    var minDate = updateTarget.OrderInformation
                         .Where(a => a.OrderInformationId > 0).Min(a => a.OrderInformationId);

                    updateTarget.OrderInformation.Remove(updateTarget.OrderInformation
                        .Where(a => a.OrderInformationId == minDate).First());
                }

                blocky.Update(updateTarget);

                context.SaveChanges();
            }

            Console.WriteLine("Performance update datamapper time to complete:" + DateTime.Now.Subtract(started).TotalSeconds.ToString());
        }
Exemplo n.º 3
0
        static void DataMapBlockOdd()
        {
            try
            {
                OrderPocoDataMapBlock dataMapBlock = new OrderPocoDataMapBlock();
                EntityFrameworkRepositoryContext<TheoreticalEntities> context = new EntityFrameworkRepositoryContext<TheoreticalEntities>();
                dataMapBlock.Context = context;

                var findResult = dataMapBlock.TryFind(134);

                var addOrder = CreateNewOrderPoco();

                addOrder.Status = StatusEnum.Giggidy;

                //sl.Add(addOrder);
                dataMapBlock.Add(addOrder);
                context.SaveChanges();

                var addFindResult = dataMapBlock.TryFind(addOrder.MyId);

                //remove last and add a new one.
                addFindResult.MyOrderPocoItems.Remove(addFindResult.MyOrderPocoItems.Last());
                addFindResult.MyOrderPocoItems.Add(new OrderItemPoco()
                {
                    HasSerialNumber = false,
                    SalePrice = 1000M,
                    SerialNumber = "ADDEDITEM",
                    RenamedUpc = "ADDUPC",
                    ConcurrencyId = 0
                });

                dataMapBlock.Update(addFindResult);
                context.SaveChanges();

                addFindResult.OrderInformation.Last().TrackingNumber = "Giggidy";

                dataMapBlock.Update(addFindResult);
                context.SaveChanges();

                dataMapBlock.Delete(addFindResult);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
        }