Beispiel #1
0
        private static ObservableCollection <SchemaModifierModel> LoadSchemaTemplates(List <SchemaModifier> userConfigTemplates,
                                                                                      DatabaseMetadata databaseMetadata, AppMetadata appMetadata)
        {
            var returnVM = new ObservableCollection <SchemaModifierModel>();

            //We show every single element from the user's config.
            var schemasToShow = userConfigTemplates;

            //We add the elements from the default metadata if not present.
            var userConfigDistinctSchemas = userConfigTemplates.Select(s => s.Name.GetSchema()).Distinct();
            var schemasToAdd = databaseMetadata.Select(s => s.Key).Distinct().Except(userConfigDistinctSchemas);

            schemasToShow.AddRange(from d in schemasToAdd select new SchemaModifier {
                Name = d
            });

            foreach (var schema in schemasToShow)
            {
                var defaultSchemaMetadata = GetSchemaMetadata(databaseMetadata, appMetadata, schema.Name);

                returnVM.Add(new SchemaModifierModel
                {
                    _name          = schema.Name,
                    _templateId    = schema.TemplateId,
                    _useTemplateId = schema.BasedOn,
                    _description   = schema.Description,
                    _tables        = LoadTableTemplates(schema.Tables, defaultSchemaMetadata)
                });
            }

            return(returnVM);
        }