示例#1
0
        /// <summary>
        /// enumerates the where-clauses for foreign keys
        /// </summary>
        public string GetForeignKeyWhere(DbRelationship rl)
        {
            var join = rl.Join;

            foreach (var col in this.Columns)
            {
                if (join.Contains(":" + col.ColumnName.ToLower()))
                {
                    join = join.Replace(":" + col.ColumnName.ToLower(), col.ScriptValue);
                }
            }
            return(join);
        }
示例#2
0
        /// <summary>
        /// fill by selecting from the specified table
        /// </summary>
        /// <param name="tbl"></param>
        public void Fill(DataTable tbl)
        {
            // get the schema from the table:
            if (SchemaInfo == null)
            {
                SchemaInfo = tbl.GetTableInfo();
            }

            int rowNum = 0;

            var where = this.WhereClause;
            if (string.IsNullOrEmpty(this.WhereClause))
            {
                where = "1=1";
            }

            foreach (var tblRow in tbl.Select(where))
            {
                var scriptRow = new DbScriptRow(this)
                {
                    RowID = rowNum++
                };


                foreach (var info in SchemaInfo)
                {
                    var            tblCol = tbl.Columns[info.ColumnName];
                    DbRelationship rl     = null;
                    if (tblCol.ExtendedProperties.ContainsKey("relationship"))
                    {
                        rl = DbRelationship.Parse(tblCol.ExtendedProperties["relationship"] as string);
                    }

                    scriptRow.Columns.Add(new DbScriptColumn(scriptRow)
                    {
                        ColumnInfo   = info,
                        Value        = tblRow[tblCol],
                        Relationship = rl
                    });
                }

                Rows.Add(scriptRow);
            }
        }