A class that wraps your database in Dynamic Funtime
コード例 #1
0
ファイル: DatabaseDetector.cs プロジェクト: Talljoe/Passive
        /// <summary>
        /// Probes the specified database.
        /// </summary>
        public DatabaseDialect Probe(DynamicDatabase database, string providerName, string connectionString)
        {
            switch (providerName)
            {
            case "System.Data.SqlClient":
                return(ProbeSqlServer(database));

            case "System.Data.SqlServerCe.4.0":
                return(new SqlCompact4Dialect());

            default:
                return(new DatabaseDialect());
            }
        }
コード例 #2
0
        /// <summary>
        /// Probes the specified database.
        /// </summary>
        public DatabaseDialect Probe(DynamicDatabase database, string providerName, string connectionString)
        {
            switch (providerName)
            {
                case "System.Data.SqlClient":
                    return ProbeSqlServer(database);

                case "System.Data.SqlServerCe.4.0":
                    return new SqlCompact4Dialect();

                default:
                    return new DatabaseDialect();
            }
        }
コード例 #3
0
        private static DatabaseDialect ProbeSqlServer(DynamicDatabase database)
        {
            string versionString;
            try
            {
                versionString = (string)database.Scalar(@"SELECT SERVERPROPERTY('productversion');");
            }
            catch (SqlException)
            {
                versionString = "0";
            }

            int version;
            if (Int32.TryParse(versionString.Split('.').First(), out version) && version > 0)
            {
                return new SqlServerDialect(version);
            }

            return null;
        }
コード例 #4
0
ファイル: DatabaseDetector.cs プロジェクト: Talljoe/Passive
        private static DatabaseDialect ProbeSqlServer(DynamicDatabase database)
        {
            string versionString;

            try
            {
                versionString = (string)database.Scalar(@"SELECT SERVERPROPERTY('productversion');");
            }
            catch (SqlException)
            {
                versionString = "0";
            }

            int version;

            if (Int32.TryParse(versionString.Split('.').First(), out version) && version > 0)
            {
                return(new SqlServerDialect(version));
            }

            return(null);
        }
コード例 #5
0
 public DatabaseDialect Probe(DynamicDatabase database, string providerName, string connectionString)
 {
     return this.dialect;
 }
コード例 #6
0
ファイル: DynamicModel.cs プロジェクト: Jabberrwocky/Passive
 /// <summary>
 /// Initializes a new instance of the <see cref="DynamicModel"/> class.
 /// </summary>
 /// <param name="database">The database.</param>
 /// <param name="tableName">Name of the table.</param>
 /// <param name="primaryKeyField">The primary key field.</param>
 public DynamicModel(DynamicDatabase database, string tableName = "", string primaryKeyField = "")
 {
     this.Database = database ?? new DynamicDatabase();
     this.TableName = tableName == "" ? this.GetType().Name : tableName;
     this.PrimaryKeyField = string.IsNullOrWhiteSpace(primaryKeyField) ? "ID" : primaryKeyField;
 }
コード例 #7
0
ファイル: DynamicModel.cs プロジェクト: Talljoe/Passive
 /// <summary>
 /// Initializes a new instance of the <see cref="DynamicModel"/> class.
 /// </summary>
 /// <param name="database">The database.</param>
 /// <param name="tableName">Name of the table.</param>
 /// <param name="primaryKeyField">The primary key field.</param>
 public DynamicModel(DynamicDatabase database, string tableName = "", string primaryKeyField = "")
 {
     this.Database        = database ?? new DynamicDatabase();
     this.TableName       = tableName == "" ? this.GetType().Name : tableName;
     this.PrimaryKeyField = string.IsNullOrWhiteSpace(primaryKeyField) ? "ID" : primaryKeyField;
 }
コード例 #8
0
ファイル: DynamicDatabase.cs プロジェクト: Talljoe/Passive
 public DatabaseDialect Probe(DynamicDatabase database, string providerName, string connectionString)
 {
     return(this.dialect);
 }