public GetParentRow ( |
||
relation | ||
리턴 |
public BaseBusinessProxy(DataRow row) { this.Name = row["Name"].ToString(); this.Version = ""; if (row.GetParentRow("Bla_Blh").Table.Columns.Contains("Version")) { this.Version = row.GetParentRow("Bla_Blh")["Version"].ToString(); } this.DbName = ""; if (row.Table.Columns.Contains("DbName")) { this.DbName = row["DbName"].ToString(); } this.TransactionMode = "false"; if (row.Table.Columns.Contains("TransactionMode")) { this.TransactionMode = row["TransactionMode"].ToString(); } if (row.Table.Columns.Contains("Provider")) { this.Provider = row["Provider"].ToString(); } try { this.BusinessAssemblyName = row.GetParentRow("Bla_Blh")["Name"].ToString(); } catch { } }
private void AddChangedRow(Hashtable addedRows, DataTable copyTable, DataRow row) { if (addedRows.ContainsKey(row)) { return; } foreach (DataRelation relation in row.Table.ParentRelations) { DataRow parent = (row.RowState != DataRowState.Deleted ? row.GetParentRow(relation) : row.GetParentRow(relation, DataRowVersion.Original) ); if (parent == null) { continue; } // add the parent row DataTable parentCopyTable = copyTable.DataSet.Tables [parent.Table.TableName]; AddChangedRow(addedRows, parentCopyTable, parent); } // add the current row DataRow newRow = copyTable.NewNotInitializedRow(); copyTable.Rows.AddInternal(newRow); // Don't check for ReadOnly, when cloning data to new uninitialized row. row.CopyValuesToRow(newRow, false); newRow.XmlRowID = row.XmlRowID; addedRows.Add(row, row); }
internal void CheckForLoops(DataRelation rel) { // don't check for loops in the diffgram // because there may be some holes in the rowCollection // and index creation may fail. The check will be done // after all the loading is done _and_ we are sure there // are no holes in the collection. if (this._Table.DataSet.fInLoadDiffgram) { return; } int count = this.Table.Rows.Count, i = 0; // need to optimize this for count > 100 DataRow parent = this.GetParentRow(rel); while (parent != null) { if ((parent == this) || (i > count)) { throw ExceptionBuilder.NestedCircular(this.Table.TableName); } i++; parent = parent.GetParentRow(rel); } }
internal override object Eval(DataRow row, DataRowVersion version) { if ((this.column == null) || (this.relation == null)) { throw ExprException.ExpressionUnbound(this.ToString()); } DataRow parentRow = row.GetParentRow(this.relation, version); if (parentRow == null) { return(DBNull.Value); } return(parentRow[this.column, parentRow.HasVersion(version) ? version : DataRowVersion.Current]); }
internal void CheckForLoops(DataRelation rel) { if (!this._table.fInLoadDiffgram && ((this._table.DataSet == null) || !this._table.DataSet.fInLoadDiffgram)) { int count = this._table.Rows.Count; int num = 0; for (DataRow row = this.GetParentRow(rel); row != null; row = row.GetParentRow(rel)) { if ((row == this) || (num > count)) { throw ExceptionBuilder.NestedCircular(this._table.TableName); } num++; } } }
internal override object Eval(DataRow row, DataRowVersion version) { if (_column == null || _relation == null) { throw ExprException.ExpressionUnbound(ToString()); } DataRow parent = row.GetParentRow(_relation, version); if (parent == null) { return(DBNull.Value); } return(parent[_column, parent.HasVersion(version) ? version : DataRowVersion.Current]); }
internal override object Eval(DataRow row, DataRowVersion version) { #if DEBUG if (CompModSwitches.LookupNode.TraceVerbose) { Debug.WriteLine("Eval " + this.ToString()); } #endif if (table == null || column == null || relation == null) { throw ExprException.ExpressionUnbound(this.ToString()); } DataRow parent = row.GetParentRow(relation, version); if (parent == null) { return(DBNull.Value); } return(parent[column, parent.HasVersion(version) ? version : DataRowVersion.Current]); // haroona : Bug 76154 }
private DataRow GetNestedParent(DataRow row) { DataRelation relation = GetNestedParentRelation(row); if (relation != null) return row.GetParentRow(relation); return null; }
private CustomSiteMapNode GetParentNodeFromDataRow(DataRow childRow) { if (childRow == null) throw new ProviderException("DataRow in SiteMap is null."); DataRow parentRow = childRow.GetParentRow(GT.DA.SiteMap.SiteMap.PARENT_CHILD_REL); if (parentRow == null) throw new ProviderException(string.Format("Cannot find parent for SiteMap node with ID {0}", childRow[GT.DA.SiteMap.SiteMap.ID_COL])); return CreateNodeFromRow(parentRow); }
internal override object Eval(DataRow row, DataRowVersion version) { if ((this.column == null) || (this.relation == null)) { throw ExprException.ExpressionUnbound(this.ToString()); } DataRow parentRow = row.GetParentRow(this.relation, version); if (parentRow == null) { return DBNull.Value; } return parentRow[this.column, parentRow.HasVersion(version) ? version : DataRowVersion.Current]; }
private void AddChangedRow (Hashtable addedRows, DataTable copyTable, DataRow row) { if (addedRows.ContainsKey (row)) return; foreach (DataRelation relation in row.Table.ParentRelations) { DataRow parent = row.GetParentRow (relation); if (parent == null) continue; // add the parent row DataTable parentCopyTable = copyTable.DataSet.Tables [parent.Table.TableName]; AddChangedRow (addedRows, parentCopyTable, parent); } // add the current row DataRow newRow = copyTable.NewNotInitializedRow(); copyTable.Rows.AddInternal(newRow); row.CopyValuesToRow (newRow); newRow.XmlRowID = row.XmlRowID; addedRows.Add (row, row); }
internal virtual void Evaluate(DataRow row, DataRowVersion version) { #if DEBUG if (CompModSwitches.DataExpression.TraceVerbose) { Debug.WriteLine("Evaluate expression column Queue, version = " + version.ToString() + " for table " + owner.TableName); } #endif Debug.Assert(columns != null, "Invalid dependensy list"); Debug.Assert(row != null, "Invalid argument to Evaluate, row"); for (int i = 0; i < columnCount; i++) { DataColumn col = columns[i]; Debug.Assert(col.Computed, "Only computed columns should be in the queue."); #if DEBUG if (CompModSwitches.DataExpression.TraceVerbose) { Debug.WriteLine("Evaluate column " + col.ColumnName + " = " + col.DataExpression.ToString()); } #endif if (col.Table == null) { continue; } if (col.Table != owner) { // first if the column belongs to an other table we need to recalc it for each row in the foreing table #if DEBUG if (CompModSwitches.DataExpression.TraceVerbose) { Debug.WriteLine("the column belong to a different table %%%%%%%"); } #endif // we need to update all foreign table - NOPE, only those who are valid parents. ALTHOUGH we're skipping old parents right now... confirm. DataRowVersion foreignVer = (version == DataRowVersion.Proposed) ? DataRowVersion.Default : version; int parentRelationCount = owner.ParentRelations.Count; for (int j = 0; j < parentRelationCount; j++) { DataRelation relation = owner.ParentRelations[j]; if (relation.ParentTable != col.Table) { continue; } DataRow parentRow = row.GetParentRow(relation, version); if (parentRow != null) { col[parentRow.GetRecordFromVersion(foreignVer)] = col.DataExpression.Evaluate(parentRow, foreignVer); } } int childRelationCount = owner.ChildRelations.Count; for (int j = 0; j < childRelationCount; j++) { DataRelation relation = owner.ChildRelations[j]; if (relation.ChildTable != col.Table) { continue; } DataRow[] childRows = row.GetChildRows(relation, version); for (int k = 0; k < childRows.Length; k++) { if (childRows[k] != null) { col[childRows[k].GetRecordFromVersion(foreignVer)] = col.DataExpression.Evaluate(childRows[k], foreignVer); } } } } else if (col.DataExpression.HasLocalAggregate()) { // if column expression references a local Table aggregate we need to recalc it for the each row in the local table DataRowVersion aggVersion = (version == DataRowVersion.Proposed) ? DataRowVersion.Default : version; #if DEBUG if (CompModSwitches.DataExpression.TraceVerbose) { Debug.WriteLine("it has local aggregate."); } #endif bool isConst = col.DataExpression.IsTableAggregate(); object val = null; if (isConst) { val = col.DataExpression.Evaluate(row, aggVersion); } DataRow[] rows = new DataRow[col.Table.Rows.Count]; col.Table.Rows.CopyTo(rows, 0); for (int j = 0; j < rows.Length; j++) { if (!isConst) { val = col.DataExpression.Evaluate(rows[j], aggVersion); } col[rows[j].GetRecordFromVersion(aggVersion)] = val; } } else { col[row.GetRecordFromVersion(version)] = col.DataExpression.Evaluate(row, version); } } }
/// <summary> /// Вернуть название объекта представленного в виде значения ключа /// </summary> /// <param name="dr">Строка описывающая сущность</param> /// <param name="columnIndex">Индекс столбца в строке, значение в котором нужно вернуть в виде текста</param> /// <returns>Текстовое представление столбца из заданной строки</returns> private string GetColumnText(DataRow dr, int columnIndex) { DataTable table = dr.Table; switch (table.TableName) { case "Movies": if (table.Columns[columnIndex].ColumnName == "genre_id") { DataRow genre = dr.GetParentRow("MovieGenre"); return genre["name"].ToString(); } break; case "Sessions": if (table.Columns[columnIndex].ColumnName == "movie_id") { DataRow movie = dr.GetParentRow("SessionMovie"); return movie["name"].ToString(); } else if (table.Columns[columnIndex].ColumnName == "cinema_id") { DataRow cinema = dr.GetParentRow("SessionCinema"); return cinema["name"].ToString(); } else if (table.Columns[columnIndex].ColumnName == "beginning") { DateTime begin = this.dataBase.GetDateFromSecond((int)dr["beginning"]); return begin.ToLongDateString() + " " + begin.ToShortTimeString(); } break; case "Tickets": if (table.Columns[columnIndex].ColumnName == "session_id") { DataRow session = dr.GetParentRow("TicketSession"); DataRow movie = session.GetParentRow("SessionMovie"); DataRow cinema = session.GetParentRow("SessionCinema"); DateTime time = this.dataBase.GetDateFromSecond((int)session["beginning"]); string column = String.Format("{0} ({1}) [{2}]", movie["name"].ToString(), cinema["name"].ToString(), time.ToShortDateString() + " " + time.ToShortTimeString()); return column; } break; default: break; } return dr[columnIndex].ToString(); }
internal override object Eval(DataRow row, DataRowVersion version) { if (column == null || relation == null) throw ExprException.ExpressionUnbound(this.ToString()); DataRow parent = row.GetParentRow(relation, version); if (parent == null) return DBNull.Value; return parent[column, parent.HasVersion(version) ? version : DataRowVersion.Current]; // [....] : Bug 76154 }
/// <summary> /// private Methode um die zugehörige Adresse, zu einer Zeile (Row) aus der lokalen Datenbank-Kunden-Tabelle, zu erhalten /// </summary> /// <param name="row"></param> /// <returns></returns> private Adresse GetAdress(DataRow row) { DataRow r = row.GetParentRow(_zuordnungKundenAdresse); return new Adresse(r["Straße"].ToString(), r["Hausnummer"].ToString(), r["Ort"].ToString(), r["PLZ"].ToString()); }
private void AddChangedRow (Hashtable addedRows, DataTable copyTable, DataRow row) { if (addedRows.ContainsKey (row)) return; foreach (DataRelation relation in row.Table.ParentRelations) { DataRow parent = ( row.RowState != DataRowState.Deleted ? row.GetParentRow (relation) : row.GetParentRow (relation, DataRowVersion.Original) ); if (parent == null) continue; // add the parent row DataTable parentCopyTable = copyTable.DataSet.Tables [parent.Table.TableName]; AddChangedRow (addedRows, parentCopyTable, parent); } // add the current row DataRow newRow = copyTable.NewNotInitializedRow (); copyTable.Rows.AddInternal (newRow); // Don't check for ReadOnly, when cloning data to new uninitialized row. row.CopyValuesToRow (newRow, false); newRow.XmlRowID = row.XmlRowID; addedRows.Add (row, row); }
public static string CodeToText(DataRow Row, string ColumnName, string TextCol, bool bIndirect) { string RetVal = ""; DataTable Table = Row.Table; for (int I = 0; I < Table.ParentRelations.Count; I++) { DataRelation Rel = Table.ParentRelations[I]; if (Rel.ChildKeyConstraint.Columns.Length == 1 && Rel.ChildKeyConstraint.Columns[0].ColumnName.ToLower().CompareTo(ColumnName.ToLower()) == 0) { DataRow ParentRow = Row.GetParentRow(Rel); try { RetVal = ParentRow[TextCol].ToString(); if (bIndirect) return CodeToText(ParentRow, TextCol, "Text", false); } catch { } break; } } return RetVal; }
public DataRow GetReferencedRow (DataRow row) { switch (refTable) { case ReferencedTable.Self: default: return row; case ReferencedTable.Parent: return row.GetParentRow (GetRelation (row)); case ReferencedTable.Child: return row.GetChildRows (GetRelation (row)) [0]; } }
public DataRow GetReferencedRow (DataRow row) { // Verify the column reference is valid GetColumn (row); switch (refTable) { case ReferencedTable.Self: default: return row; case ReferencedTable.Parent: return row.GetParentRow (GetRelation (row)); case ReferencedTable.Child: return row.GetChildRows (GetRelation (row)) [0]; } }
/// <summary> /// 绑定字段单元格数值 /// </summary> /// <param name="xeField">单元格数据节点</param> /// <param name="dataRow">绑定行</param> /// <returns>已经绑定返回true</returns> private bool BindData(XmlElement xeField, DataRow dataRow) { if (null == xeField || null == dataRow) return true; string alias=xeField.GetAttribute("alias"); string field=xeField.GetAttribute("field"); string key = dataRow.Table.TableName; PrintInfo pinfo = null; if (this.printInfoList.ContainsKey(key)) pinfo = this.printInfoList[key]; if (null != pinfo && (alias == pinfo.AliasName || alias == key)) { if (!dataRow.Table.Columns.Contains(field)) { xeField.InnerText = ""; return true; } object v = dataRow[field]; if (null == v || DBNull.Value == v) xeField.InnerText = ""; if (true.Equals(v)) xeField.InnerText = "√"; else if (false.Equals(v)) xeField.InnerText = "×"; else xeField.InnerText = Convert.ToString(v); return true; } if (string.IsNullOrEmpty(alias) && dataRow.Table.Columns.Contains(field)) { if (!dataRow.Table.Columns.Contains(field)) { xeField.InnerText = ""; return true; } object vf = dataRow[field]; if(null == vf || DBNull.Value == vf) xeField.InnerText = ""; if (true.Equals(vf)) xeField.InnerText = "√"; else if (false.Equals(vf)) xeField.InnerText = "×"; else xeField.InnerText = Convert.ToString(vf); return true; } foreach (DataRelation r in dataRow.Table.ParentRelations) if (this.BindData(xeField, dataRow.GetParentRow(r))) return true; return false; }