Exemple #1
0
        public override EntityCollection RetrieveEntities(Model model)
        {
            Entity           ent;
            EntityCollection entities = new EntityCollection();

            DS.SchemaReader.EntitiesDataTable dt = new CodeGenerator.BL.DBReader.DS.SchemaReader.EntitiesDataTable();

            DS.SchemaReaderTableAdapters.EntitiesTableAdapter adp = new CodeGenerator.BL.DBReader.DS.SchemaReaderTableAdapters.EntitiesTableAdapter();
            adp.Connection = new System.Data.SqlClient.SqlConnection(base.ConnectionString);

            adp.Fill(dt, Filter.IncludeTablesAsEntities, Filter.IncludeViewAsEntities, Filter.IncludeForignTables, Filter.SchemasAsCSV());
            base.EntityCount = dt.Rows.Count;
            if (WorkerThread != null && WorkerThread.WorkerReportsProgress)
            {
                WorkerThread.ReportProgress(0);
            }
            int count = 1;

            foreach (DS.SchemaReader.EntitiesRow row in dt.Rows)
            {
                ent             = new Entity();
                ent.Model       = model;
                ent.DBName      = row.TABLE_NAME;
                ent.Schema      = row.TABLE_SCHEMA;
                ent.EntityID    = row.OBJECT_ID.ToString();
                ent.LogicalName = row.TABLE_NAME;

                FillProperties(ent, adp.Connection, null, "schema", ent.Schema, "table", ent.DBName);
                LogicalNameGenerator gen = new LogicalNameGenerator();
                gen.GenerateLogicalName(ent);
                entities.Add(ent);
                if (WorkerThread != null && WorkerThread.WorkerReportsProgress)
                {
                    WorkerThread.ReportProgress((count / base.EntityCount) * 100);
                }
                count++;
            }
            return(entities);
        }
        public override EntityCollection RetrieveEntities(Model model)
        {
            Entity ent;
            EntityCollection entities = new EntityCollection();
            DS.SchemaReader.EntitiesDataTable dt = new CodeGenerator.BL.DBReader.DS.SchemaReader.EntitiesDataTable();

            DS.SchemaReaderTableAdapters.EntitiesTableAdapter adp = new CodeGenerator.BL.DBReader.DS.SchemaReaderTableAdapters.EntitiesTableAdapter();
            adp.Connection = new System.Data.SqlClient.SqlConnection(base.ConnectionString);

            adp.Fill(dt , Filter.IncludeTablesAsEntities, Filter.IncludeViewAsEntities, Filter.IncludeForignTables,Filter.SchemasAsCSV() );
            base.EntityCount = dt.Rows.Count;
            if (WorkerThread != null && WorkerThread.WorkerReportsProgress)
            {
                WorkerThread.ReportProgress(0);
            }
            int count = 1;
            foreach (DS.SchemaReader.EntitiesRow row in dt.Rows)
            {
                ent = new Entity();
                ent.Model = model;
                ent.DBName = row.TABLE_NAME;
                ent.Schema = row.TABLE_SCHEMA;
                ent.EntityID = row.OBJECT_ID.ToString();
                ent.LogicalName =   row.TABLE_NAME;

                FillProperties(ent, adp.Connection, null, "schema", ent.Schema, "table", ent.DBName);
                LogicalNameGenerator gen = new LogicalNameGenerator();
                gen.GenerateLogicalName(ent);
                entities.Add(ent);
                if (WorkerThread != null && WorkerThread.WorkerReportsProgress)
                {
                    WorkerThread.ReportProgress((count / base.EntityCount)*100);
                }
                count++;
            }
            return entities;
        }