Exemple #1
0
        /// <summary>
        /// Gets the update table schema SQL.
        /// </summary>
        public static SqlBatch GetUpdateTableSql(this IDataHelper dh, Type modelType)
        {
            List <SqlBatch> sqls            = new List <SqlBatch>();
            var             columnNameDic   = AttributeHelper.GetProp2ColumnNameDics(dh.Driver.DirverType, modelType);
            var             colIndexs       = AttributeHelper.GetColumn2IndexNameDics(dh.Driver.DirverType, modelType);
            var             primaryKeyProps = AttributeHelper.GetPrimaryKeys(dh.Driver.DirverType, modelType, false);
            var             createDdls      = AttributeHelper.GetPropertyName2DDLs(dh.Driver.DirverType, modelType, dh.Driver.TypeMapping);
            var             tableName       = AttributeHelper.GetTableName(modelType, false, null);
            ConcurrentDictionary <string, string> columnDdls = new ConcurrentDictionary <string, string>();

            foreach (var ddl in createDdls)
            {
                columnDdls.TryAdd(columnNameDic[ddl.Key], ddl.Value);
            }
            var      primaryKeyColumns = primaryKeyProps.ConvertToAll(p => columnNameDic[p]);
            SqlBatch sql = dh.Driver.GetUpdateTableSql(tableName, columnDdls, primaryKeyColumns, colIndexs);

            return(sql);
        }