예제 #1
0
        static void SimpleThingy()
        {
            SimpleRepoThingy repo = new SimpleRepoThingy();

            //set the juicy context...
            var efContext = new TheoreticalEntities();
            efContext.Configuration.LazyLoadingEnabled = false;
            efContext.Configuration.ProxyCreationEnabled = false;
            //efContext.Configuration.ValidateOnSaveEnabled = false;
            var context = new DataMapper.Repositories.EntityFrameworkRepositoryContext<TheoreticalEntities>(efContext);
            repo.Context = context;

            var findResult = repo.TryFind(134);

            var addOrder = CreateNewOrderEntity();

            //addOrder.RenamedStatus = StatusEnum.Giggidy;

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

            var addFindResult = repo.TryFind(addOrder.OrderId);

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

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

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

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

            repo.Delete(addFindResult);
            context.SaveChanges();
        }
예제 #2
0
        static void DataMapBlock()
        {
            try
            {
                OrderDataMapBlock dataMapBlock = new OrderDataMapBlock();

                //set the juicy context...
                var efContext = new TheoreticalEntities();
                efContext.Configuration.LazyLoadingEnabled = false;
                efContext.Configuration.ProxyCreationEnabled = false;
                //efContext.Configuration.ValidateOnSaveEnabled = false;
                var context = new DataMapper.Repositories.EntityFrameworkRepositoryContext<TheoreticalEntities>(efContext);
                dataMapBlock.Context = context;

                var findResult = dataMapBlock.TryFind(134);

                var addOrder = CreateNewOrder();
                //sl.Add(addOrder);
                dataMapBlock.Add(addOrder);
                context.SaveChanges();

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

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

                addFindResult.MultiKey.Remove(addFindResult.MultiKey.First());
                addFindResult.MultiKey.Add(new MultiKey()
                {
                    KeyOne = 100,
                    KeyTwo = Guid.NewGuid(),
                    KeyThree = "GiggidyUp",
                    Name= "Multi",
                    Number= "23333",
                    ConcurrencyId = 99
                });

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

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

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

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

                Order whatever;
                Order whatever2;
                using (var tranny = new System.Transactions.TransactionScope())
                {
                    whatever = CreateNewOrder();
                    whatever.Number = "F**k";
                    dataMapBlock.Add(whatever);
                    context.SaveChanges();

                    whatever2 = CreateNewOrder();
                    whatever2.Number = "YeahMan";
                    dataMapBlock.Add(whatever2);
                    context.SaveChanges();

                    tranny.Complete();
                }

                whatever = whatever;
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }