示例#1
0
        public static string ToInsertString(this CDataset dataset, int testRows = 1)
        {
            var query       = new StringBuilder();
            var independent = from t in dataset.Table
                              where !(from r in dataset.Relationship
                                      select r.fromTable).Distinct().Contains(t.name)
                              select t;
            var dependent = from t in dataset.Table
                            where !(from r in dataset.Relationship
                                    select r.toTable).Distinct().Contains(t.name)
                            select t;
            var interdependent = from t in dataset.Table
                                 where !independent.Contains(t) && !dependent.Contains(t)
                                 orderby t.name
                                 select t;

            independent.ToList().ForEach(t =>
            {
                query.Append(t.ToInsertString(testRows));
            });
            interdependent.ToList().ForEach(t =>
            {
                query.Append(t.ToInsertString(testRows));
            });
            dependent.ToList().ForEach(t =>
            {
                query.Append(t.ToInsertString(testRows));
            });

            return(query.ToString());
        }
示例#2
0
        public static string ToSchemaDropString(this CDataset dataset)
        {
            var query = new StringBuilder();

            dataset.Table.ToList().ForEach(t =>
            {
                query.Append(t.ToSchemaDropString());
            });

            return(query.ToString());
        }
示例#3
0
        public static DataSet ToDataSet(this CDataset dataset)
        {
            var ds = new DataSet(dataset.name);

            foreach (var t in dataset.Table)
            {
                ds.Tables.Add(t.ToDataTable(100));
            }

            return(ds);
        }
示例#4
0
        public static CTable ToTable(this CDataset dataset)
        {
            var table = new CTable {
                name = dataset.name
            };

            table.Column.Add(new CColumn {
                DbType = eDbType.@string, name = "name"
            });
            table.Column.Add(new CColumn {
                DbType = eDbType.@int, name = "columns"
            });
            return(table);
        }
示例#5
0
        public static DataTable ToDataTable(this CDataset dataset, int top = 100)
        {
            var table = new DataTable(dataset.name);

            table.Columns.AddRange(new DataColumn[] {
                new DataColumn("name", typeof(string)),
                new DataColumn("columns", typeof(int))
            });

            foreach (var t in dataset.Table.Take(top))
            {
                var row = table.NewRow();
                row["name"]    = t.name;
                row["columns"] = t.Column.Count;
                table.Rows.Add(row);
            }

            return(table);
        }
示例#6
0
        public static string ToSchemaString(this CDataset dataset)
        {
            var query       = new StringBuilder();
            var independent = from t in dataset.Table
                              where !(from r in dataset.Relationship
                                      select r.fromTable).Distinct().Contains(t.name)
                              select t;
            var dependent = from t in dataset.Table
                            where !(from r in dataset.Relationship
                                    select r.toTable).Distinct().Contains(t.name)
                            select t;
            var interdependent = from t in dataset.Table
                                 where !independent.Contains(t) && !dependent.Contains(t)
                                 select t;

            dependent.ToList().ForEach(t =>
            {
                //query.Append(t.ToSchemaDropString());
                query.Append(t.ToSchemaString());
            });
            independent.ToList().ForEach(t =>
            {
                //query.Append(t.ToSchemaDropString());
                query.Append(t.ToSchemaString());
            });
            interdependent.ToList().ForEach(t =>
            {
                //query.Append(t.ToSchemaDropString());
                query.Append(t.ToSchemaString());
            });

            dataset.Relationship.ToList().ForEach(r =>
            {
                query.Append(r.ToConstraint());
            });

            return(query.ToString());
        }