Ejemplo n.º 1
0
        public List <MetaInformationSchema> GetMetaInformationSchemaFromLists(List.InformationSchemaTable tables,
                                                                              List.InformationSchemaTableConstraint tableConstraints,
                                                                              List.InformationSchemaColumn tableColumns,
                                                                              List.InformationSchemaConstraintColumnUsage constraintColumnUsage)
        {
            List <MetaInformationSchema> allSchemas         = new List <MetaInformationSchema>();
            PredicateFunctions           predicateFunctions = new PredicateFunctions();

            if (tables != null)
            {
                foreach (Data.InformationSchemaTable table in tables)
                {
                    MetaInformationSchema oneSchema = new MetaInformationSchema();
                    oneSchema.MetaTable = table;

                    predicateFunctions.TableNameHolder = table.TableName;

                    if (tableConstraints != null)
                    {
                        oneSchema.MetaTableConstraints.AddRange(tableConstraints.FindAll(predicateFunctions.FindTableConstraintByTableName));
                    }
                    if (tableColumns != null)
                    {
                        oneSchema.MetaColumns.AddRange(tableColumns.FindAll(predicateFunctions.FindTableColumnByTableName));
                    }
                    if (constraintColumnUsage != null)
                    {
                        oneSchema.MetaConstraintColumnUsage.AddRange(constraintColumnUsage.FindAll(predicateFunctions.FindConstraintColumnUsageByTableName));
                    }
                    allSchemas.Add(oneSchema);
                }
            }
            return(allSchemas);
        }
Ejemplo n.º 2
0
        private List <MetaInformationSchema> GetSchemaForUserTables(SqlDataReader schemaReader)
        {
            List.InformationSchemaTable                 tables                = null;
            List.InformationSchemaTableConstraint       tableConstraints      = null;
            List.InformationSchemaColumn                tableColumns          = null;
            List.InformationSchemaConstraintColumnUsage constraintColumnUsage = null;

            using (schemaReader)
            {
                int count = 0;
                do
                {
                    switch (count)
                    {
                    case (int)Sproc.Mapping.AllResultSets.INFORMATION_SCHEMA_TABLE:
                    {
                        tables =
                            new SprocDataLayerGenerator.List.InformationSchemaTable(schemaReader);
                        break;
                    }

                    case (int)Sproc.Mapping.AllResultSets.INFORMATION_SCHEMA_TABLE_CONSTRAINTS:
                    {
                        tableConstraints =
                            new SprocDataLayerGenerator.List.InformationSchemaTableConstraint(schemaReader);
                        break;
                    }

                    case (int)Sproc.Mapping.AllResultSets.INFORMATION_SCHEMA_COLUMN:
                    {
                        tableColumns =
                            new SprocDataLayerGenerator.List.InformationSchemaColumn(schemaReader);
                        break;
                    }

                    case (int)Sproc.Mapping.AllResultSets.INFORMATION_SCHEMA_CONSTRAINT_COLUMN_USAGE:
                    {
                        constraintColumnUsage =
                            new SprocDataLayerGenerator.List.InformationSchemaConstraintColumnUsage(schemaReader);
                        break;
                    }
                    }
                    count++;
                } while (schemaReader.NextResult());
            }

            return(GetMetaInformationSchemaFromLists(tables, tableConstraints, tableColumns, constraintColumnUsage));
        }