Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataSet / System / Data / TypedTableBaseExtensions.cs / 1305376 / 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
- _ProxyRegBlob.cs
- TemplatePropertyEntry.cs
- CodeTypeDelegate.cs
- ShutDownListener.cs
- XmlBaseReader.cs
- EntityDataSourceValidationException.cs
- FileLogRecordHeader.cs
- Missing.cs
- MenuItem.cs
- NetWebProxyFinder.cs
- MergeLocalizationDirectives.cs
- SectionInput.cs
- DocumentXPathNavigator.cs
- VirtualPathProvider.cs
- StringExpressionSet.cs
- ControlUtil.cs
- EditorZoneDesigner.cs
- AssertFilter.cs
- Bidi.cs
- DocumentViewerBaseAutomationPeer.cs
- ResourceFallbackManager.cs
- _TLSstream.cs
- DBCommandBuilder.cs
- XPathDocument.cs
- DataGridItem.cs
- AssemblyInfo.cs
- TextPointerBase.cs
- PartialList.cs
- WindowsGraphics.cs
- ReadOnlyHierarchicalDataSource.cs
- JavaScriptObjectDeserializer.cs
- FixedTextContainer.cs
- FreezableDefaultValueFactory.cs
- AddressHeader.cs
- AuthorizationRule.cs
- ObjectQueryState.cs
- ExtensionDataObject.cs
- Cloud.cs
- XPathParser.cs
- UnsupportedPolicyOptionsException.cs
- TargetControlTypeCache.cs
- IItemContainerGenerator.cs
- Debugger.cs
- InfoCardService.cs
- CodeGen.cs
- BitConverter.cs
- EntityDataSourceSelectingEventArgs.cs
- Timeline.cs
- RectIndependentAnimationStorage.cs
- LoginName.cs
- ItemsPresenter.cs
- BitmapEffectvisualstate.cs
- AsymmetricKeyExchangeFormatter.cs
- Brush.cs
- SecurityUniqueId.cs
- Vector3DConverter.cs
- ServiceRoute.cs
- TdsParserStateObject.cs
- ListViewEditEventArgs.cs
- Identity.cs
- DbExpressionBuilder.cs
- BindStream.cs
- DataGridViewAutoSizeModeEventArgs.cs
- ParseHttpDate.cs
- AxHost.cs
- TraceLog.cs
- XmlDataCollection.cs
- uribuilder.cs
- ExtendedProtectionPolicy.cs
- TreeNodeMouseHoverEvent.cs
- EntityModelSchemaGenerator.cs
- OpenFileDialog.cs
- WindowsIdentity.cs
- CommonDialog.cs
- ScalarType.cs
- ScriptReference.cs
- DragDeltaEventArgs.cs
- PrintingPermission.cs
- SoapExtension.cs
- AttachedPropertyDescriptor.cs
- KeyMatchBuilder.cs
- ShutDownListener.cs
- DelegatingHeader.cs
- StorageComplexTypeMapping.cs
- HtmlInputCheckBox.cs
- BuildProvidersCompiler.cs
- XmlQualifiedNameTest.cs
- BoundingRectTracker.cs
- ConnectionManagementElement.cs
- DataObjectMethodAttribute.cs
- _NegoStream.cs
- DbProviderFactory.cs
- WorkflowMessageEventHandler.cs
- DecoderFallbackWithFailureFlag.cs
- XmlAnyAttributeAttribute.cs
- DataServiceException.cs
- Crypto.cs
- SHA512Managed.cs
- NativeMethods.cs
- WebPartConnectVerb.cs