Ejemplo n.º 1
0
 public void FlushCache()
 {
     using (var context = new LiteDispatchDbContext(new ModelCreator()))
       {
     context.Database.ExecuteSqlCommand("TRUNCATE TABLE PascalRecords");
       }
 }
Ejemplo n.º 2
0
 public void FlushCache()
 {
     using (var context = new LiteDispatchDbContext(new ModelCreator()))
     {
         context.Database.ExecuteSqlCommand("TRUNCATE TABLE PascalRecords");
     }
 }
Ejemplo n.º 3
0
            public SimpleMembershipInitializer()
            {
                Database.SetInitializer <UsersContext>(null);

                try
                {
                    using (var context = new UsersContext())
                    {
                        if (!context.Database.Exists())
                        {
                            // Create the SimpleMembership database without Entity Framework migration schema
                            ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                        }
                    }

                    WebSecurity.InitializeDatabaseConnection("SecurityDb", "UserProfile", "UserId", "UserName", autoCreateTables: true);
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
                }

                using (var context = new LiteDispatchDbContext(new ModelCreator()))
                {
                    if (context.Database.Exists())
                    {
                        return;
                    }
                    context.Database.CreateIfNotExists();
                    using (var transManager = Container.GlobalContext.TransFactory.CreateManager())
                    {
                        transManager.ExecuteCommand(locator =>
                        {
                            var haulier = locator.FindAll <Haulier>().SingleOrDefault(h => h.Name == "BlueWhale");
                            if (haulier != null)
                            {
                                return(Mapper.Map <Haulier, HaulierModel>(haulier));
                            }
                            haulier = Haulier.Create(locator, new HaulierModel {
                                Name = "BlueWhale"
                            });
                            return(Mapper.Map <Haulier, HaulierModel>(haulier));
                        });
                    }
                }
            }
            public SimpleMembershipInitializer()
            {
                Database.SetInitializer<UsersContext>(null);

                try
                {
                  using (var context = new UsersContext())
                  {
                if (!context.Database.Exists())
                {
                  // Create the SimpleMembership database without Entity Framework migration schema
                  ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                }
                  }

                  WebSecurity.InitializeDatabaseConnection("SecurityDb", "UserProfile", "UserId", "UserName", autoCreateTables: true);
                }
                catch (Exception ex)
                {
                  throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
                }

                using (var context = new LiteDispatchDbContext(new ModelCreator()))
                {
                  if (context.Database.Exists()) return;
                  context.Database.CreateIfNotExists();
                  using (var transManager = Container.GlobalContext.TransFactory.CreateManager())
                  {
                transManager.ExecuteCommand(locator =>
                  {
                var haulier = locator.FindAll<Haulier>().SingleOrDefault(h => h.Name == "BlueWhale");
                if (haulier != null)
                {
                  return Mapper.Map<Haulier, HaulierModel>(haulier);
                }
                haulier = Haulier.Create(locator, new HaulierModel { Name = "BlueWhale" });
                return Mapper.Map<Haulier, HaulierModel>(haulier);
                  });
                  }
                }
            }
Ejemplo n.º 5
0
        public PascalRequestModel CalculateLevel(int level)
        {
            List<PascalRecord> results = null;
              var startTime = DateTime.Now;
              using (var context = new LiteDispatchDbContext(new ModelCreator()))
              {
            for (int i = 0; i < 10; i++)
            {
              var parameter = new SqlParameter("@level", level);
              results = context.Database.SqlQuery<PascalRecord>("GetPascalPyramidLevel @level", parameter).ToList();
            }
              }
              var endTime = DateTime.Now;
              var diff = endTime.Subtract(startTime);
              var res = String.Format("{0} hrs {1} mins {2} secs {3} millisecs", diff.Hours, diff.Minutes, diff.Seconds, diff.Milliseconds);

              return new PascalRequestModel
            {
              Level = level,
              ElapsedTime = res,
              PascalRecords = results
            };
        }
Ejemplo n.º 6
0
        public PascalRequestModel CalculateLevel(int level)
        {
            List <PascalRecord> results = null;
            var startTime = DateTime.Now;

            using (var context = new LiteDispatchDbContext(new ModelCreator()))
            {
                for (int i = 0; i < 10; i++)
                {
                    var parameter = new SqlParameter("@level", level);
                    results = context.Database.SqlQuery <PascalRecord>("GetPascalPyramidLevel @level", parameter).ToList();
                }
            }
            var endTime = DateTime.Now;
            var diff    = endTime.Subtract(startTime);
            var res     = String.Format("{0} hrs {1} mins {2} secs {3} millisecs", diff.Hours, diff.Minutes, diff.Seconds, diff.Milliseconds);

            return(new PascalRequestModel
            {
                Level = level,
                ElapsedTime = res,
                PascalRecords = results
            });
        }
Ejemplo n.º 7
0
 public DomainDbManager(LiteDispatchDbContext context)
 {
     ModelCreator = context.ModelCreator;
 }
 public DomainSqlCeDbManager(LiteDispatchDbContext context)
     : base(context)
 {
 }
Ejemplo n.º 9
0
 public DomainDbManager(LiteDispatchDbContext context)
 {
     ModelCreator = context.ModelCreator;
 }
Ejemplo n.º 10
0
 public DomainSqlCeDbManager(LiteDispatchDbContext context) : base(context)
 {
 }