public static PostgreQpDataContext Create(DbConnection connection)
        {
            var optionsBuilder = new DbContextOptionsBuilder <PostgreQpDataContext>();

            optionsBuilder.UseNpgsql <PostgreQpDataContext>(connection);
            var ctx = new PostgreQpDataContext(optionsBuilder.Options);

            ctx.SiteName         = DefaultSiteName;
            ctx.ConnectionString = connection.ConnectionString;
            return(ctx);
        }
        public static PostgreQpDataContext Create(IMappingConfigurator configurator, DbConnection connection)
        {
            var mapping        = configurator.GetMappingInfo();
            var optionsBuilder = new DbContextOptionsBuilder <PostgreQpDataContext>();

            optionsBuilder.UseNpgsql <PostgreQpDataContext>(connection);
            optionsBuilder.UseModel(mapping.DbCompiledModel);
            PostgreQpDataContext ctx = new PostgreQpDataContext(optionsBuilder.Options, mapping.Schema);

            ctx.SiteName         = mapping.Schema.Schema.SiteName;
            ctx.ConnectionString = connection.ConnectionString;
            return(ctx);
        }
        public static PostgreQpDataContext Create(string connection, string siteName)
        {
            PostgreQpDataContext ctx;

            if (connection.IndexOf("metadata", StringComparison.InvariantCultureIgnoreCase) == -1)
            {
                var optionsBuilder = new DbContextOptionsBuilder <PostgreQpDataContext>();
                optionsBuilder.UseNpgsql <PostgreQpDataContext>(connection);
                ctx                  = new PostgreQpDataContext(optionsBuilder.Options);
                ctx.SiteName         = siteName;
                ctx.ConnectionString = connection;
                return(ctx);
            }
            else
            {
                var optionsBuilder = new DbContextOptionsBuilder <PostgreQpDataContext>();
                optionsBuilder.UseNpgsql <PostgreQpDataContext>(connection);
                ctx                  = new PostgreQpDataContext(optionsBuilder.Options);
                ctx.SiteName         = siteName;
                ctx.ConnectionString = connection;
                return(ctx);
            }
        }
示例#4
0
 void OnContextCreated()
 {
     Current = this;
 }