예제 #1
0
        private DbTypeInfo GetDbTypeInfo <TEntity>()
            where TEntity : IDbEntity, new()
        {
            Type       entityType = typeof(TEntity);
            DbTypeInfo entityDbTypeInfo;

            if (!DbConnection.dbTypeInfo.TryGetValue(entityType, out entityDbTypeInfo))
            {
                IDbEntity        defaultEntity          = new TEntity();
                SchemaCollection entitySchemaCollection = new SchemaCollection();

                foreach (DbOperationInfo operation in defaultEntity.DbOperations.Values)
                {
                    if (operation.ParameterType != null && !entitySchemaCollection.Contains(operation.ParameterType))
                    {
                        DataTable schemaTable = this.GetSchema(operation.ParameterType);
                        entitySchemaCollection.Add(schemaTable);
                    }
                }

                entityDbTypeInfo = new DbTypeInfo()
                {
                    DefaultEntity = defaultEntity,
                    SchemaInfo    = entitySchemaCollection
                };

                DbConnection.dbTypeInfo[entityType] = entityDbTypeInfo;
            }

            return(entityDbTypeInfo);
        }
예제 #2
0
        private string CompareSchemas(
            SchemaCollection sourceSchemas,
            SchemaCollection targetSchema
            )
        {
            var returnScript = "";

            foreach (Schema item in sourceSchemas)
            {
                if (!item.IsSystemObject && !targetSchema.Contains(item.Name))
                {
                    returnScript += "CREATE SCHEMA [" + item.Name + "] AUTHORIZATION [" + item.Owner + "];" + Environment.NewLine + "GO" + Environment.NewLine;
                }
            }
            return(returnScript);
        }