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

            string connection = ActiveConnections.Get("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 DbCtxNorthwindEntities CreateDbContext()
        {
            DbCtxNorthwindEntities context = null;

            string connection = ActiveConnections.Get("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);
        }
Пример #3
0
        protected override EFCFNorthwindEntities CreateDbContext()
        {
            EFCFNorthwindEntities context = null;

            string connection = ActiveConnections.Get("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);
        }
Пример #4
0
        protected override NorthwindEntities CreateObjectContext()
        {
            NorthwindEntities context = null;

            string connection = ActiveConnections.Get("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);
        }
Пример #5
0
        protected override EFCFNorthwindEntities CreateDbContext()
        {
            EFCFNorthwindEntities context = null;

            string connection = ActiveConnections.Get("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
                //"data source=Alexappfxss01;Persist Security Info=True;User ID=RiaTest;Password=TestPassword;MultipleActiveResultSets=True;Database=Northwind_Light"
                connection = string.Format("Persist Security Info=True;MultipleActiveResultSets=True;{0}", connection);
                //connection = "Data Source=AlexAppFxss02;Initial Catalog=Northwind;Persist Security Info=True;User ID=RiaTest;Password=TestPassword;MultipleActiveResultSets=True";
                context = new EFCFNorthwindEntities(connection);
            }
            else
            {
                context = base.CreateDbContext();
            }

            return(context);
        }