private void AppendIdentifier(EntitySet table, Action <string> AppendIdentifierEscape) { string schemaName = SqlDdlBuilder.GetSchemaName(table); string tableName = SqlDdlBuilder.GetTableName(table); if (schemaName != null) { AppendIdentifierEscape(schemaName); this.AppendSql("."); } AppendIdentifierEscape(tableName); }
internal static string CreateObjectsScript( StoreItemCollection itemCollection, bool createSchemas) { SqlDdlBuilder sqlDdlBuilder = new SqlDdlBuilder(); foreach (EntityContainer entityContainer in itemCollection.GetItems <EntityContainer>()) { IOrderedEnumerable <EntitySet> source = entityContainer.BaseEntitySets.OfType <EntitySet>().OrderBy <EntitySet, string>((Func <EntitySet, string>)(s => s.Name)); if (createSchemas) { foreach (string schema in (IEnumerable <string>) new HashSet <string>(source.Select <EntitySet, string>((Func <EntitySet, string>)(s => SqlDdlBuilder.GetSchemaName(s)))).OrderBy <string, string>((Func <string, string>)(s => s))) { if (schema != "dbo") { sqlDdlBuilder.AppendCreateSchema(schema); } } } foreach (EntitySet entitySet in (IEnumerable <EntitySet>)entityContainer.BaseEntitySets.OfType <EntitySet>().OrderBy <EntitySet, string>((Func <EntitySet, string>)(s => s.Name))) { sqlDdlBuilder.AppendCreateTable(entitySet); } foreach (AssociationSet associationSet in (IEnumerable <AssociationSet>)entityContainer.BaseEntitySets.OfType <AssociationSet>().OrderBy <AssociationSet, string>((Func <AssociationSet, string>)(s => s.Name))) { sqlDdlBuilder.AppendCreateForeignKeys(associationSet); } } return(sqlDdlBuilder.GetCommandText()); }