Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / DynamicData / DynamicData / ModelProviders / AssociationProvider.cs / 1305376 / AssociationProvider.cs
using System.Collections.ObjectModel; using System.Globalization; using System.Web.Resources; namespace System.Web.DynamicData.ModelProviders { ////// Specifies the association cardinality /// public enum AssociationDirection { ////// 1-1 /// OneToOne, ////// one to many /// OneToMany, ////// many to one /// ManyToOne, ////// many to many /// ManyToMany } ////// Base provider class for associations between columns /// Each provider type (e.g. Linq To Sql, Entity Framework, 3rd party) extends this class. /// public abstract class AssociationProvider { private TableProvider _toTable; ////// The type of association /// public virtual AssociationDirection Direction { get; protected set; } ////// The source column of the association /// public virtual ColumnProvider FromColumn { get; protected set; } ////// The destination table of the association /// public virtual TableProvider ToTable { get { if (_toTable != null) { return _toTable; } if (ToColumn != null) { return ToColumn.Table; } return null; } protected set { _toTable = value; } } ////// The destination column of the association /// public virtual ColumnProvider ToColumn { get; protected set; } ////// Returns true if the From Column part of the primary key of its table /// e.g. Order and Product are PKs in the Order_Details table /// public virtual bool IsPrimaryKeyInThisTable { get; protected set; } ////// The names of the underlying foreign keys that make up this association /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification="It's a readonly collection, so the warning is incorrect")] public virtual ReadOnlyCollectionForeignKeyNames { get; protected set; } /// /// Returns a string representing the sort expression that would be used for /// sorting the column represented by this association. The parameter is the /// property of the strongly typed entity used as the sort key for that entity. /// For example, assume that this association represents the Category column /// in the Products table. The sortColumn paramater is "CategoryName", /// meaning that this method is being asked to return the sort expression for /// sorting the Category column by the CategoryName property of the Category entity. /// The result sort expression would be "Category.CategoryName". /// The result of this method should be affected by whether the underlying data /// model is capable of sorting the entity by the given sort column (see /// ColumnProvider.IsSortable). The method can return a null value to indicate /// that sorting is not supported. /// /// the column to sort the entity by ///the sort expression string, or null if sort is not supported for the /// given sort column public virtual string GetSortExpression(ColumnProvider sortColumn) { return null; } internal string GetSortExpression(ColumnProvider sortColumn, string format) { if (Direction == AssociationDirection.OneToMany || Direction == AssociationDirection.ManyToMany) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.AssociationProvider_DirectionDoesNotSupportSorting, Direction)); } if (sortColumn == null) { throw new ArgumentNullException("sortColumn"); } if (!ToTable.Columns.Contains(sortColumn)) { throw new ArgumentException(DynamicDataResources.AssociationProvider_SortColumnDoesNotBelongToEndTable, "sortColumn"); } if (sortColumn.IsSortable) { return String.Format(CultureInfo.InvariantCulture, format, FromColumn.Name, sortColumn.Name); } else { return null; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System.Collections.ObjectModel; using System.Globalization; using System.Web.Resources; namespace System.Web.DynamicData.ModelProviders { ////// Specifies the association cardinality /// public enum AssociationDirection { ////// 1-1 /// OneToOne, ////// one to many /// OneToMany, ////// many to one /// ManyToOne, ////// many to many /// ManyToMany } ////// Base provider class for associations between columns /// Each provider type (e.g. Linq To Sql, Entity Framework, 3rd party) extends this class. /// public abstract class AssociationProvider { private TableProvider _toTable; ////// The type of association /// public virtual AssociationDirection Direction { get; protected set; } ////// The source column of the association /// public virtual ColumnProvider FromColumn { get; protected set; } ////// The destination table of the association /// public virtual TableProvider ToTable { get { if (_toTable != null) { return _toTable; } if (ToColumn != null) { return ToColumn.Table; } return null; } protected set { _toTable = value; } } ////// The destination column of the association /// public virtual ColumnProvider ToColumn { get; protected set; } ////// Returns true if the From Column part of the primary key of its table /// e.g. Order and Product are PKs in the Order_Details table /// public virtual bool IsPrimaryKeyInThisTable { get; protected set; } ////// The names of the underlying foreign keys that make up this association /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification="It's a readonly collection, so the warning is incorrect")] public virtual ReadOnlyCollectionForeignKeyNames { get; protected set; } /// /// Returns a string representing the sort expression that would be used for /// sorting the column represented by this association. The parameter is the /// property of the strongly typed entity used as the sort key for that entity. /// For example, assume that this association represents the Category column /// in the Products table. The sortColumn paramater is "CategoryName", /// meaning that this method is being asked to return the sort expression for /// sorting the Category column by the CategoryName property of the Category entity. /// The result sort expression would be "Category.CategoryName". /// The result of this method should be affected by whether the underlying data /// model is capable of sorting the entity by the given sort column (see /// ColumnProvider.IsSortable). The method can return a null value to indicate /// that sorting is not supported. /// /// the column to sort the entity by ///the sort expression string, or null if sort is not supported for the /// given sort column public virtual string GetSortExpression(ColumnProvider sortColumn) { return null; } internal string GetSortExpression(ColumnProvider sortColumn, string format) { if (Direction == AssociationDirection.OneToMany || Direction == AssociationDirection.ManyToMany) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.AssociationProvider_DirectionDoesNotSupportSorting, Direction)); } if (sortColumn == null) { throw new ArgumentNullException("sortColumn"); } if (!ToTable.Columns.Contains(sortColumn)) { throw new ArgumentException(DynamicDataResources.AssociationProvider_SortColumnDoesNotBelongToEndTable, "sortColumn"); } if (sortColumn.IsSortable) { return String.Format(CultureInfo.InvariantCulture, format, FromColumn.Name, sortColumn.Name); } else { return null; } } } } // 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
- PersonalizablePropertyEntry.cs
- GridViewPageEventArgs.cs
- CustomErrorsSection.cs
- DocumentsTrace.cs
- MediaScriptCommandRoutedEventArgs.cs
- TypeUtil.cs
- XmlLoader.cs
- DrawingContextWalker.cs
- StylusButtonCollection.cs
- CodeCatchClauseCollection.cs
- RectangleGeometry.cs
- EventMemberCodeDomSerializer.cs
- DefaultProxySection.cs
- EventTask.cs
- ReflectPropertyDescriptor.cs
- XmlAnyElementAttributes.cs
- ClientSettingsSection.cs
- ListMarkerLine.cs
- SplashScreen.cs
- BindingSource.cs
- AffineTransform3D.cs
- RegexCapture.cs
- PageThemeCodeDomTreeGenerator.cs
- ComponentEditorPage.cs
- DataService.cs
- HyperLinkColumn.cs
- EndOfStreamException.cs
- FileDialog_Vista.cs
- MouseGestureConverter.cs
- ExpressionValueEditor.cs
- TraceLevelStore.cs
- TripleDES.cs
- ListBindingConverter.cs
- SID.cs
- DrawingGroup.cs
- IntegerFacetDescriptionElement.cs
- DefaultHttpHandler.cs
- DataObjectFieldAttribute.cs
- OletxTransactionFormatter.cs
- CodeAssignStatement.cs
- DataGridViewIntLinkedList.cs
- ObjectQueryProvider.cs
- HttpConfigurationContext.cs
- SubstitutionList.cs
- X509Certificate2Collection.cs
- ConnectionStringsExpressionBuilder.cs
- ContainerUIElement3D.cs
- DataGridRow.cs
- WebPartEditVerb.cs
- DbProviderManifest.cs
- _ChunkParse.cs
- NamespaceExpr.cs
- NameSpaceExtractor.cs
- PseudoWebRequest.cs
- ValueSerializer.cs
- Options.cs
- XmlUtf8RawTextWriter.cs
- ExclusiveNamedPipeTransportManager.cs
- StrokeCollection2.cs
- OutKeywords.cs
- NativeMethods.cs
- BaseHashHelper.cs
- JsonServiceDocumentSerializer.cs
- PaintEvent.cs
- ExpressionReplacer.cs
- AutomationPeer.cs
- Span.cs
- Pkcs7Signer.cs
- SqlMethodAttribute.cs
- DeploymentSection.cs
- HiddenFieldPageStatePersister.cs
- AspProxy.cs
- SingleResultAttribute.cs
- ConfigurationValidatorAttribute.cs
- ISessionStateStore.cs
- EventLogPermissionEntryCollection.cs
- MouseActionValueSerializer.cs
- FileRecordSequenceCompletedAsyncResult.cs
- Expr.cs
- WebDescriptionAttribute.cs
- FragmentQueryKB.cs
- DefaultValueTypeConverter.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- AlignmentYValidation.cs
- PasswordDeriveBytes.cs
- RankException.cs
- DefaultEvaluationContext.cs
- RectangleGeometry.cs
- DataRelationPropertyDescriptor.cs
- ToolStripOverflow.cs
- ToolBarTray.cs
- VisualStyleInformation.cs
- MaskInputRejectedEventArgs.cs
- SystemTcpStatistics.cs
- RemoteWebConfigurationHostStream.cs
- MasterPageBuildProvider.cs
- ListControl.cs
- NamedPipeDuplicateContext.cs
- IntersectQueryOperator.cs
- GB18030Encoding.cs