Beispiel #1
0
        public static QpDataContext Create(DbConnection connection)
        {
            var optionsBuilder = new DbContextOptionsBuilder <QpDataContext>();

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

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

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

            ctx.SiteName         = mapping.Schema.Schema.SiteName;
            ctx.ConnectionString = connection.ConnectionString;
            return(ctx);
        }
Beispiel #3
0
        public static QpDataContext Create(string connection, string siteName)
        {
            QpDataContext ctx;

            if (connection.IndexOf("metadata", StringComparison.InvariantCultureIgnoreCase) == -1)
            {
                var optionsBuilder = new DbContextOptionsBuilder <QpDataContext>();
                optionsBuilder.UseNpgsql <QpDataContext>(connection);
                ctx                  = new QpDataContext(optionsBuilder.Options);
                ctx.SiteName         = siteName;
                ctx.ConnectionString = connection;
                return(ctx);
            }
            else
            {
                var optionsBuilder = new DbContextOptionsBuilder <QpDataContext>();
                optionsBuilder.UseNpgsql <QpDataContext>(connection);
                ctx                  = new QpDataContext(optionsBuilder.Options);
                ctx.SiteName         = siteName;
                ctx.ConnectionString = connection;
                return(ctx);
            }
        }