Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Data / System / Data / Filter / LookupNode.cs / 3 / LookupNode.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
// [....]
//-----------------------------------------------------------------------------
namespace System.Data {
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
internal sealed class LookupNode : ExpressionNode {
private readonly string relationName; // can be null
private readonly string columnName;
private DataColumn column;
private DataRelation relation;
internal LookupNode(DataTable table, string columnName, string relationName) : base(table) {
this.relationName = relationName;
this.columnName = columnName;
}
internal override void Bind(DataTable table, List list) {
BindTable(table);
column = null; // clear for rebinding (if original binding was valid)
relation = null;
if (table == null)
throw ExprException.ExpressionUnbound(this.ToString());
// First find parent table
DataRelationCollection relations;
relations = table.ParentRelations;
if (relationName == null) {
// must have one and only one relation
if (relations.Count > 1) {
throw ExprException.UnresolvedRelation(table.TableName, this.ToString());
}
relation = relations[0];
}
else {
relation = relations[relationName];
}
if (null == relation) {
throw ExprException.BindFailure(relationName);// WebData 112162: this operation is not clne specific, throw generic exception
}
DataTable parentTable = relation.ParentTable;
Debug.Assert(relation != null, "Invalid relation: no parent table.");
Debug.Assert(columnName != null, "All Lookup expressions have columnName set.");
this.column = parentTable.Columns[columnName];
if (column == null)
throw ExprException.UnboundName(columnName);
// add column to the dependency list
int i;
for (i = 0; i < list.Count; i++) {
// walk the list, check if the current column already on the list
DataColumn dataColumn = list[i];
if (column == dataColumn) {
break;
}
}
if (i >= list.Count) {
list.Add(column);
}
//
AggregateNode.Bind(relation, list);
}
internal override object Eval() {
throw ExprException.EvalNoContext();
}
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
}
internal override object Eval(int[] recordNos) {
throw ExprException.ComputeNotAggregate(this.ToString());
}
internal override bool IsConstant() {
return false;
}
internal override bool IsTableConstant() {
return false;
}
internal override bool HasLocalAggregate() {
return false;
}
internal override bool HasRemoteAggregate() {
return false;
}
internal override bool DependsOn(DataColumn column) {
if (this.column == column) {
return true;
}
return false;
}
internal override ExpressionNode Optimize() {
return this;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ListItemCollection.cs
- VirtualizedItemPattern.cs
- RootBrowserWindowAutomationPeer.cs
- Normalization.cs
- InputScopeManager.cs
- SQLDateTime.cs
- ResourceIDHelper.cs
- versioninfo.cs
- QilIterator.cs
- BindingList.cs
- XmlCustomFormatter.cs
- BmpBitmapEncoder.cs
- DataGridAutoFormat.cs
- IndexedEnumerable.cs
- UInt32Storage.cs
- FrameworkRichTextComposition.cs
- DataGridViewCellParsingEventArgs.cs
- SafeSecurityHelper.cs
- DocumentViewer.cs
- StringAttributeCollection.cs
- ColumnCollection.cs
- CheckBoxField.cs
- WebContext.cs
- ProfileGroupSettingsCollection.cs
- XmlDataSourceView.cs
- FamilyTypeface.cs
- Drawing.cs
- BoolExpression.cs
- WCFBuildProvider.cs
- ControlDesigner.cs
- Font.cs
- TableLayoutPanel.cs
- ItemCollection.cs
- AmbientProperties.cs
- ReverseInheritProperty.cs
- IProvider.cs
- Currency.cs
- DeclarationUpdate.cs
- AttributedMetaModel.cs
- CodeTypeReferenceExpression.cs
- HMACSHA384.cs
- WindowProviderWrapper.cs
- OracleCommandSet.cs
- CollectionViewGroup.cs
- OdbcParameterCollection.cs
- ResourceExpressionBuilder.cs
- QilLiteral.cs
- ConfigurationFileMap.cs
- XmlComment.cs
- NameValuePair.cs
- UnitySerializationHolder.cs
- CultureSpecificStringDictionary.cs
- ModelItemExtensions.cs
- GB18030Encoding.cs
- WindowsListViewScroll.cs
- MenuRendererStandards.cs
- AppDomain.cs
- GridProviderWrapper.cs
- JsonDeserializer.cs
- SrgsSubset.cs
- CancellationHandlerDesigner.cs
- DataControlFieldCollection.cs
- OptimizedTemplateContentHelper.cs
- CodeCastExpression.cs
- TableCellCollection.cs
- ArrayElementGridEntry.cs
- ResourceDisplayNameAttribute.cs
- _DisconnectOverlappedAsyncResult.cs
- PeerApplication.cs
- TransactionManager.cs
- DeleteMemberBinder.cs
- adornercollection.cs
- RandomDelayQueuedSendsAsyncResult.cs
- ToolStripArrowRenderEventArgs.cs
- MessageEncoderFactory.cs
- TypeReference.cs
- XmlNamespaceManager.cs
- BinaryNode.cs
- XmlTextReader.cs
- MimeMultiPart.cs
- nulltextcontainer.cs
- ALinqExpressionVisitor.cs
- ErrorHandlerModule.cs
- ContainerActivationHelper.cs
- StringWriter.cs
- SystemIPInterfaceProperties.cs
- PrinterSettings.cs
- StringValidatorAttribute.cs
- HtmlInputPassword.cs
- ExecutionEngineException.cs
- CompositeActivityMarkupSerializer.cs
- SqlClientMetaDataCollectionNames.cs
- XmlTextReader.cs
- HandoffBehavior.cs
- BaseUriHelper.cs
- XmlSecureResolver.cs
- TextDecorations.cs
- Version.cs
- PersonalizationEntry.cs
- TextEffectCollection.cs