A class that wraps your database in Dynamic Funtime
示例#1
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());
            }
        }
示例#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
        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
 /// <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
 /// <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
 public DatabaseDialect Probe(DynamicDatabase database, string providerName, string connectionString)
 {
     return(this.dialect);
 }