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
- PageCodeDomTreeGenerator.cs
- IDQuery.cs
- WhitespaceSignificantCollectionAttribute.cs
- SingleConverter.cs
- HierarchicalDataSourceControl.cs
- OleDbMetaDataFactory.cs
- SqlRemoveConstantOrderBy.cs
- SettingsPropertyWrongTypeException.cs
- TypeContext.cs
- XmlNavigatorFilter.cs
- Int16AnimationBase.cs
- BinaryExpression.cs
- MsmqIntegrationProcessProtocolHandler.cs
- SystemException.cs
- PeerIPHelper.cs
- PeerCollaboration.cs
- PackUriHelper.cs
- UIElement.cs
- SmiContext.cs
- StrokeIntersection.cs
- CompilerResults.cs
- SharedStatics.cs
- HtmlWindow.cs
- HiddenFieldDesigner.cs
- SqlDataSourceFilteringEventArgs.cs
- TreeBuilderBamlTranslator.cs
- BaseResourcesBuildProvider.cs
- Stackframe.cs
- SimpleTypeResolver.cs
- documentsequencetextpointer.cs
- TextUtf8RawTextWriter.cs
- ReceiveErrorHandling.cs
- DoubleLink.cs
- DropDownButton.cs
- InputDevice.cs
- BinaryUtilClasses.cs
- DataGridComponentEditor.cs
- ImageUrlEditor.cs
- PeerToPeerException.cs
- DiagnosticsConfigurationHandler.cs
- BehaviorEditorPart.cs
- XmlSchemaSimpleContentRestriction.cs
- ScrollBar.cs
- MaskedTextBox.cs
- PeerSecurityHelpers.cs
- CancelEventArgs.cs
- DrawingState.cs
- NetworkAddressChange.cs
- BinaryUtilClasses.cs
- AppDomainAttributes.cs
- ISAPIApplicationHost.cs
- _SingleItemRequestCache.cs
- RangeValidator.cs
- ParamArrayAttribute.cs
- DecoderReplacementFallback.cs
- DecimalSumAggregationOperator.cs
- x509store.cs
- SessionState.cs
- _LocalDataStoreMgr.cs
- XmlWellformedWriter.cs
- ValidatingReaderNodeData.cs
- CachedRequestParams.cs
- ProxyDataContractResolver.cs
- RewritingProcessor.cs
- PassportPrincipal.cs
- ClientTargetCollection.cs
- StorageComplexTypeMapping.cs
- ActivityExecutorSurrogate.cs
- RegexMatchCollection.cs
- CodeCompiler.cs
- ConfigDefinitionUpdates.cs
- MatrixTransform3D.cs
- TableSectionStyle.cs
- Int32KeyFrameCollection.cs
- InputBindingCollection.cs
- XPathExpr.cs
- SRef.cs
- Debug.cs
- FixedStringLookup.cs
- ConstraintCollection.cs
- Evaluator.cs
- ConnectionPoolManager.cs
- DataBinder.cs
- HandleExceptionArgs.cs
- ReturnValue.cs
- BaseCodePageEncoding.cs
- __ConsoleStream.cs
- FirstMatchCodeGroup.cs
- WorkflowMarkupSerializer.cs
- DataListCommandEventArgs.cs
- InputProviderSite.cs
- TextElement.cs
- PackWebRequest.cs
- HttpCacheVary.cs
- MemoryPressure.cs
- HandlerWithFactory.cs
- XmlNodeReader.cs
- NativeCompoundFileAPIs.cs
- SqlFactory.cs
- DropDownList.cs