Пример #1
0
        protected override NorthwindDataContext CreateDataContext()
        {
            NorthwindDataContext context = null;

            string connection = DBImager.GetNewDatabaseConnectionString("Northwind");

            if (!string.IsNullOrEmpty(connection))
            {
                // if there is an active connection in scope use it
                context = new NorthwindDataContext(connection);
            }
            else
            {
                context = base.CreateDataContext();
            }

            return(context);
        }
Пример #2
0
        protected override EFCFNorthwindEntities CreateDbContext()
        {
            EFCFNorthwindEntities context = null;

            string connection = DBImager.GetNewDatabaseConnectionString("Northwind");

            if (!string.IsNullOrEmpty(connection))
            {
                // if there is an active connection in scope use it
                // Here we have to append the mapping file info to the connection string
                connection = string.Format("Persist Security Info=True;MultipleActiveResultSets=True;{0}", connection);
                context    = new EFCFNorthwindEntities(connection);
            }
            else
            {
                context = base.CreateDbContext();
            }

            return(context);
        }
Пример #3
0
        protected override DbCtxNorthwindEntities CreateDbContext()
        {
            DbCtxNorthwindEntities context = null;

            string connection = DBImager.GetNewDatabaseConnectionString("Northwind");

            if (!string.IsNullOrEmpty(connection))
            {
                // if there is an active connection in scope use it
                // Here we have to append the mapping file info to the connection string
                connection = string.Format("metadata=res://*/Northwind.NorthwindDbCtx.csdl|res://*/Northwind.NorthwindDbCtx.ssdl|res://*/Northwind.NorthwindDbCtx.msl;provider=System.Data.SqlClient;provider connection string=\"{0}\"", connection);
                context    = new DbCtxNorthwindEntities(connection);
            }
            else
            {
                context = base.CreateDbContext();
            }

            return(context);
        }
Пример #4
0
        protected override NorthwindEntities CreateObjectContext()
        {
            NorthwindEntities context = null;

            string connection = DBImager.GetNewDatabaseConnectionString("Northwind");

            if (!string.IsNullOrEmpty(connection))
            {
                // if there is an active connection in scope use it
                var builder = new EntityConnectionStringBuilder();
                builder.ConnectionString         = ConfigurationManager.ConnectionStrings[NorthwindEntities.ConnectionStringName].ConnectionString;
                builder.ProviderConnectionString = connection;
                context = new NorthwindEntities(builder.ConnectionString);
            }
            else
            {
                context = base.CreateObjectContext();
            }

            return(context);
        }