Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / Filter / LookupNode.cs / 1305376 / 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, Listlist) { 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); } // SQLBU 383715: Staleness of computed values in expression column as the relationship end columns are not being added to the dependent column list. 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. // //[....] //[....] //[....] //----------------------------------------------------------------------------- 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, Listlist) { 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); } // SQLBU 383715: Staleness of computed values in expression column as the relationship end columns are not being added to the dependent column list. 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WindowsStartMenu.cs
- AsyncOperationManager.cs
- XsltContext.cs
- InfoCardX509Validator.cs
- DocumentViewerBaseAutomationPeer.cs
- ThicknessConverter.cs
- HMACRIPEMD160.cs
- FixedSOMPageConstructor.cs
- X509PeerCertificateAuthentication.cs
- LogicalExpr.cs
- CharKeyFrameCollection.cs
- SourceSwitch.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- SingleConverter.cs
- IisNotInstalledException.cs
- DiscoveryClientProtocol.cs
- HitTestWithGeometryDrawingContextWalker.cs
- SecureConversationDriver.cs
- PageOutputColor.cs
- AlignmentXValidation.cs
- HtmlHead.cs
- DocobjHost.cs
- DbProviderSpecificTypePropertyAttribute.cs
- CachedTypeface.cs
- PublisherIdentityPermission.cs
- wmiprovider.cs
- VideoDrawing.cs
- DateTimeSerializationSection.cs
- PropertyGridEditorPart.cs
- AnnotationMap.cs
- XmlUTF8TextWriter.cs
- _SafeNetHandles.cs
- TraceInternal.cs
- RC2.cs
- CompiledQuery.cs
- ToolStripPanelRenderEventArgs.cs
- GPPOINT.cs
- AuditLog.cs
- Point3DValueSerializer.cs
- ParseHttpDate.cs
- MediaPlayerState.cs
- RevocationPoint.cs
- StringPropertyBuilder.cs
- Region.cs
- ByteStorage.cs
- ElementMarkupObject.cs
- TransactionWaitAsyncResult.cs
- EdmMember.cs
- XmlSignificantWhitespace.cs
- FontWeight.cs
- BoundField.cs
- EventData.cs
- SymmetricAlgorithm.cs
- columnmapfactory.cs
- DeviceFiltersSection.cs
- GZipDecoder.cs
- DataGridCommandEventArgs.cs
- SQLInt16Storage.cs
- TypeLoadException.cs
- RenderingBiasValidation.cs
- ExceptionUtil.cs
- ResourceKey.cs
- ComplexPropertyEntry.cs
- EmptyEnumerable.cs
- EndOfStreamException.cs
- TypeSystem.cs
- ParseHttpDate.cs
- QueryOutputWriter.cs
- HtmlInputCheckBox.cs
- ComponentEditorForm.cs
- XomlCompilerError.cs
- AnimationLayer.cs
- WsiProfilesElementCollection.cs
- TextServicesCompartmentContext.cs
- ListArgumentProvider.cs
- TextCompositionEventArgs.cs
- ContractCodeDomInfo.cs
- DataSetUtil.cs
- EncodingInfo.cs
- XsltConvert.cs
- SqlInfoMessageEvent.cs
- GiveFeedbackEventArgs.cs
- WindowsRichEditRange.cs
- RSAProtectedConfigurationProvider.cs
- ExpressionBindingCollection.cs
- DataBoundControl.cs
- DateTimeOffsetStorage.cs
- SortQuery.cs
- GeometryDrawing.cs
- SiblingIterators.cs
- XPathScanner.cs
- ReaderOutput.cs
- BuiltInPermissionSets.cs
- RtfNavigator.cs
- MethodExpr.cs
- EntityCodeGenerator.cs
- DataConnectionHelper.cs
- CollectionEditorDialog.cs
- ObjectPropertyMapping.cs
- AttributeAction.cs