Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- NumericUpDownAcceleration.cs
- ImageButton.cs
- _FtpDataStream.cs
- TemplateField.cs
- ExpressionParser.cs
- XmlValueConverter.cs
- FilteredDataSetHelper.cs
- MatrixTransform3D.cs
- RouteParametersHelper.cs
- AdjustableArrowCap.cs
- ClientUtils.cs
- TcpConnectionPoolSettings.cs
- GraphicsContainer.cs
- XmlCharType.cs
- PackageStore.cs
- entityreference_tresulttype.cs
- AdornerPresentationContext.cs
- ConfigurationPropertyAttribute.cs
- BitmapSourceSafeMILHandle.cs
- ReverseInheritProperty.cs
- SQLBytesStorage.cs
- XmlCodeExporter.cs
- DelimitedListTraceListener.cs
- formatter.cs
- FragmentQueryProcessor.cs
- DelegatingConfigHost.cs
- TemplateNameScope.cs
- ClientConfigurationSystem.cs
- SortFieldComparer.cs
- PasswordTextContainer.cs
- SpecialFolderEnumConverter.cs
- TypedTableBaseExtensions.cs
- ProfilePropertyNameValidator.cs
- BrowserCapabilitiesCompiler.cs
- InvokeMethod.cs
- StringPropertyBuilder.cs
- SqlTypeSystemProvider.cs
- EventWaitHandleSecurity.cs
- WebPartMenu.cs
- ProviderSettings.cs
- PropertyDescriptor.cs
- RegexMatchCollection.cs
- BitmapFrameDecode.cs
- BrowserDefinitionCollection.cs
- EventBuilder.cs
- XmlDataLoader.cs
- GridToolTip.cs
- coordinatorfactory.cs
- MailHeaderInfo.cs
- ConfigurationProviderException.cs
- InstalledFontCollection.cs
- StylusPointPropertyId.cs
- RoutedPropertyChangedEventArgs.cs
- ViewgenContext.cs
- EditorZoneBase.cs
- XamlTypeMapperSchemaContext.cs
- PenCursorManager.cs
- ApplicationSettingsBase.cs
- TopClause.cs
- SystemColors.cs
- DriveNotFoundException.cs
- PropertyConverter.cs
- BitmapEffectGroup.cs
- DbProviderFactoriesConfigurationHandler.cs
- counter.cs
- GetLedgerRequest.cs
- MetadataItem.cs
- WorkerRequest.cs
- TableLayoutStyleCollection.cs
- GradientStop.cs
- ProtectedProviderSettings.cs
- DiagnosticsElement.cs
- ErrorLog.cs
- MultipleViewProviderWrapper.cs
- XhtmlBasicPanelAdapter.cs
- RootBrowserWindowProxy.cs
- TreeViewHitTestInfo.cs
- WebServiceEnumData.cs
- Win32PrintDialog.cs
- SponsorHelper.cs
- DesignerTransactionCloseEvent.cs
- ScriptHandlerFactory.cs
- ImageEditor.cs
- regiisutil.cs
- FileSecurity.cs
- StrokeCollection.cs
- Rotation3DAnimationUsingKeyFrames.cs
- InheritanceContextHelper.cs
- ExpressionBuilder.cs
- CustomBinding.cs
- EdgeModeValidation.cs
- LockCookie.cs
- StreamGeometryContext.cs
- OptimizedTemplateContentHelper.cs
- PageRequestManager.cs
- ProviderConnectionPointCollection.cs
- DetailsViewModeEventArgs.cs
- ComponentChangingEvent.cs
- ExpressionNormalizer.cs
- AppLevelCompilationSectionCache.cs