Пример #1
0
 public void SaveAll()
 {
     try
     {
         ent.SaveChanges();
     }
     catch (DbEntityValidationException e)
     {
         foreach (var ev in e.EntityValidationErrors)
         {
         }
     }
 }
Пример #2
0
        public static void Initialize()
        {
            SQL_entity         context = new SQL_entity();
            SECTOR             sector;
            List <SECTOR_MASK> masks = new List <SECTOR_MASK>();
            Random             rand  = new Random();

            context.SECTOR_NAMES.RemoveRange(from s in context.SECTOR_NAMES select s);
            context.SECTOR_MASKS.RemoveRange(from s in context.SECTOR_MASKS select s);
            context.REFMERCHANTS.RemoveRange(from s in context.REFMERCHANTS select s);

            List <SECTOR> names = new List <SECTOR>();

            sector = new SECTOR {
                SECTOR_NAME = @"Retail&Telecom"
            };
            masks.Add(new SECTOR_MASK {
                MASK = @"((retail(.*)telecom)|(telecom(.*)retail))", SECTOR = sector
            });
            sector = new SECTOR {
                SECTOR_NAME = @"Travel$Restaurants"
            };
            masks.Add(new SECTOR_MASK {
                MASK = @"((travel(.*)restaurants)|(restaurants(.*)travel))", SECTOR = sector
            });
            sector = new SECTOR {
                SECTOR_NAME = @"ECOMM"
            };
            masks.Add(new SECTOR_MASK {
                MASK = @"((.*)ECOMM(.*))", SECTOR = sector
            });
            sector = new SECTOR {
                SECTOR_NAME = @"Hotels"
            };
            masks.Add(new SECTOR_MASK {
                MASK = @"((.*)hotels(.*))", SECTOR = sector
            });
            foreach (SECTOR_MASK ms in masks)
            {
                context.SECTOR_MASKS.Add(ms);
            }
            context.SaveChanges();

            List <REFMERCHANTS> rf = new List <REFMERCHANTS>();
            int    upper           = rand.Next(1000, 3000);
            int    merch_gen       = rand.Next(29000000, 59999999);
            long   merch_solid     = 9000000000;
            string merch           = merch_solid.ToString();

            for (int i = 0; i < upper; i++)
            {
                merch_solid = 9000000000;
                int type1 = rand.Next(290000000, 299999999);
                int type2 = rand.Next(590000000, 599999999);

                if (type1 % 2 == 0)
                {
                    merch_solid += type1;
                }
                else
                {
                    merch_solid += type2;
                }

                merch = merch_solid.ToString();
                context.REFMERCHANTS.Add(new REFMERCHANTS {
                    ITEM_ID = merch_solid.ToString(), USER_ID = 0
                });
            }
            context.SaveChanges();
        }