Ejemplo n.º 1
0
        public void ConnectionStringsSecurityTest()
        {
            var connection = ConnectionStringsSecurity.GetConnectionString(KsmedEntities.ConnectionString);

            Assert.IsNotNull(connection);

            connection.Open();

            Assert.AreEqual(System.Data.ConnectionState.Open, connection.State);

            connection.Close();
        }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     Console.WriteLine("Test connection to database");
     Console.WriteLine("ConnectionString:");
     Console.WriteLine(ConnectionStringsSecurity.GetConnectionString(null).ConnectionString);
     try
     {
         using (var context = ContextFactory.GetNewContext())
         {
             var test = context.Users.ToArray();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Exception :");
         var currentEx = ex;
         while (currentEx != null)
         {
             Console.WriteLine(currentEx.Message);
             currentEx = currentEx.InnerException;
         }
     }
 }
Ejemplo n.º 3
0
        private static SqlConnection GetConnection(bool admin)
        {
            var connectionString = ConnectionStringsSecurity.GetConnectionString(admin ? "name=KsmedEntitiesAdmin" : KsmedEntities.ConnectionString);

            return(new SqlConnection(connectionString.StoreConnection.ConnectionString));
        }