Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataSet / System / Data / TypedTableBaseExtensions.cs / 1 / TypedTableBaseExtensions.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Globalization; using System.Diagnostics; namespace System.Data { ////// This static class defines the extension methods that add LINQ operator functionality /// within IEnumerableDT and IOrderedEnumerableDT. /// public static class TypedTableBaseExtensions { ////// LINQ's Where operator for generic EnumerableRowCollection. /// public static EnumerableRowCollectionWhere ( this TypedTableBase source, Func predicate) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); EnumerableRowCollection erc = new EnumerableRowCollection ((DataTable)source); return erc.Where (predicate); } /// /// LINQ's OrderBy operator for generic EnumerableRowCollection. /// public static OrderedEnumerableRowCollectionOrderBy ( this TypedTableBase source, Func keySelector) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); EnumerableRowCollection erc = new EnumerableRowCollection ((DataTable)source); return erc.OrderBy (keySelector); } /// /// LINQ's OrderBy operator for generic EnumerableRowCollection. /// public static OrderedEnumerableRowCollectionOrderBy ( this TypedTableBase source, Func keySelector, IComparer comparer) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); EnumerableRowCollection erc = new EnumerableRowCollection ((DataTable)source); return erc.OrderBy (keySelector, comparer); } /// /// LINQ's OrderByDescending operator for generic EnumerableRowCollection. /// public static OrderedEnumerableRowCollectionOrderByDescending ( this TypedTableBase source, Func keySelector) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); EnumerableRowCollection erc = new EnumerableRowCollection ((DataTable)source); return erc.OrderByDescending (keySelector); } /// /// LINQ's OrderByDescending operator for generic EnumerableRowCollection. /// public static OrderedEnumerableRowCollectionOrderByDescending ( this TypedTableBase source, Func keySelector, IComparer comparer) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); EnumerableRowCollection erc = new EnumerableRowCollection ((DataTable)source); return erc.OrderByDescending (keySelector, comparer); } /// /// Executes a Select (Projection) on EnumerableDataTable. If the selector returns a different /// type than the type of rows, then AsLinqDataView is disabled, and the returning EnumerableDataTable /// represents an enumerable over the LINQ Query. /// public static EnumerableRowCollectionSelect( this TypedTableBase source, Func selector) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); EnumerableRowCollection erc = new EnumerableRowCollection ((DataTable)source); return erc.Select (selector); } /// /// This method returns a IEnumerable of TRow. /// /// /// The source DataTable to make enumerable. /// ////// IEnumerable of datarows. /// public static EnumerableRowCollectionAsEnumerable (this TypedTableBase source) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); return new EnumerableRowCollection (source as DataTable); } } //end class } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Globalization; using System.Diagnostics; namespace System.Data { ////// This static class defines the extension methods that add LINQ operator functionality /// within IEnumerableDT and IOrderedEnumerableDT. /// public static class TypedTableBaseExtensions { ////// LINQ's Where operator for generic EnumerableRowCollection. /// public static EnumerableRowCollectionWhere ( this TypedTableBase source, Func predicate) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); EnumerableRowCollection erc = new EnumerableRowCollection ((DataTable)source); return erc.Where (predicate); } /// /// LINQ's OrderBy operator for generic EnumerableRowCollection. /// public static OrderedEnumerableRowCollectionOrderBy ( this TypedTableBase source, Func keySelector) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); EnumerableRowCollection erc = new EnumerableRowCollection ((DataTable)source); return erc.OrderBy (keySelector); } /// /// LINQ's OrderBy operator for generic EnumerableRowCollection. /// public static OrderedEnumerableRowCollectionOrderBy ( this TypedTableBase source, Func keySelector, IComparer comparer) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); EnumerableRowCollection erc = new EnumerableRowCollection ((DataTable)source); return erc.OrderBy (keySelector, comparer); } /// /// LINQ's OrderByDescending operator for generic EnumerableRowCollection. /// public static OrderedEnumerableRowCollectionOrderByDescending ( this TypedTableBase source, Func keySelector) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); EnumerableRowCollection erc = new EnumerableRowCollection ((DataTable)source); return erc.OrderByDescending (keySelector); } /// /// LINQ's OrderByDescending operator for generic EnumerableRowCollection. /// public static OrderedEnumerableRowCollectionOrderByDescending ( this TypedTableBase source, Func keySelector, IComparer comparer) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); EnumerableRowCollection erc = new EnumerableRowCollection ((DataTable)source); return erc.OrderByDescending (keySelector, comparer); } /// /// Executes a Select (Projection) on EnumerableDataTable. If the selector returns a different /// type than the type of rows, then AsLinqDataView is disabled, and the returning EnumerableDataTable /// represents an enumerable over the LINQ Query. /// public static EnumerableRowCollectionSelect( this TypedTableBase source, Func selector) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); EnumerableRowCollection erc = new EnumerableRowCollection ((DataTable)source); return erc.Select (selector); } /// /// This method returns a IEnumerable of TRow. /// /// /// The source DataTable to make enumerable. /// ////// IEnumerable of datarows. /// public static EnumerableRowCollectionAsEnumerable (this TypedTableBase source) where TRow : DataRow { DataSetUtil.CheckArgumentNull(source, "source"); return new EnumerableRowCollection (source as DataTable); } } //end class } // 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
- JsonReaderWriterFactory.cs
- CreateUserWizard.cs
- ToolStripSeparatorRenderEventArgs.cs
- DataTableMapping.cs
- ArraySubsetEnumerator.cs
- FullTextBreakpoint.cs
- LineGeometry.cs
- CompilerInfo.cs
- LayoutSettings.cs
- ViewStateModeByIdAttribute.cs
- CalendarData.cs
- ToolStripItemImageRenderEventArgs.cs
- ErrorFormatterPage.cs
- StateRuntime.cs
- HitTestParameters3D.cs
- ProfessionalColorTable.cs
- MimeXmlReflector.cs
- NegatedCellConstant.cs
- GreenMethods.cs
- StateElement.cs
- HostingEnvironment.cs
- NotSupportedException.cs
- MetaType.cs
- TextHidden.cs
- InvalidWMPVersionException.cs
- ReaderWriterLockWrapper.cs
- ImpersonationContext.cs
- MultiTrigger.cs
- ConstraintStruct.cs
- WsatConfiguration.cs
- ByteAnimation.cs
- NativeObjectSecurity.cs
- PageHandlerFactory.cs
- DataGridViewTopRowAccessibleObject.cs
- WebBrowsableAttribute.cs
- TimelineGroup.cs
- MetadataItem_Static.cs
- ActivationArguments.cs
- TableCellCollection.cs
- VisualTreeUtils.cs
- DotExpr.cs
- Maps.cs
- WebBrowsableAttribute.cs
- SocketAddress.cs
- FragmentQuery.cs
- EntityCommand.cs
- ToolStripOverflow.cs
- EDesignUtil.cs
- LocalizableResourceBuilder.cs
- DeflateStream.cs
- SelectionEditingBehavior.cs
- SqlRetyper.cs
- RealizedColumnsBlock.cs
- DesignerSerializerAttribute.cs
- ComponentCodeDomSerializer.cs
- CachedPathData.cs
- KeyedHashAlgorithm.cs
- SystemDiagnosticsSection.cs
- FamilyTypefaceCollection.cs
- StandardBindingOptionalReliableSessionElement.cs
- FrameworkContextData.cs
- SiblingIterators.cs
- ExplicitDiscriminatorMap.cs
- ObjectItemAttributeAssemblyLoader.cs
- EntityDesignerDataSourceView.cs
- SelectionChangedEventArgs.cs
- _AutoWebProxyScriptEngine.cs
- PropertyConverter.cs
- UrlEncodedParameterWriter.cs
- RemoteCryptoRsaServiceProvider.cs
- ExtensionSimplifierMarkupObject.cs
- MatrixTransform3D.cs
- ProviderIncompatibleException.cs
- MessageDecoder.cs
- DataTableClearEvent.cs
- MethodBody.cs
- TypeForwardedToAttribute.cs
- XmlDataSourceNodeDescriptor.cs
- StringArrayConverter.cs
- SqlUtils.cs
- StyleModeStack.cs
- XmlReaderSettings.cs
- BaseUriWithWildcard.cs
- ResXResourceSet.cs
- GroupStyle.cs
- Win32NamedPipes.cs
- WpfGeneratedKnownProperties.cs
- DataServiceKeyAttribute.cs
- OracleCommandSet.cs
- MsmqOutputChannel.cs
- Effect.cs
- XPathPatternParser.cs
- MouseCaptureWithinProperty.cs
- XmlComment.cs
- FlowDocumentFormatter.cs
- RightsManagementPermission.cs
- SelectionItemPattern.cs
- ComboBox.cs
- ScriptReferenceEventArgs.cs
- ComContractElementCollection.cs