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
- DataColumnMappingCollection.cs
- HtmlShimManager.cs
- WebResourceUtil.cs
- WebPartConnectionsDisconnectVerb.cs
- MailBnfHelper.cs
- Point3D.cs
- unitconverter.cs
- RulePatternOps.cs
- UInt16.cs
- Action.cs
- StringAnimationUsingKeyFrames.cs
- SqlBulkCopyColumnMapping.cs
- Membership.cs
- Span.cs
- ObjectParameterCollection.cs
- FlowDocument.cs
- ListBoxItemAutomationPeer.cs
- XmlSerializationReader.cs
- AttachedAnnotation.cs
- Imaging.cs
- XmlTextReader.cs
- AsymmetricSecurityProtocol.cs
- StrokeIntersection.cs
- EntryWrittenEventArgs.cs
- InputQueue.cs
- ReferencedType.cs
- MemberNameValidator.cs
- SQLInt64.cs
- Accessible.cs
- SqlProcedureAttribute.cs
- ResourcePermissionBaseEntry.cs
- IssuedTokenParametersElement.cs
- RegularExpressionValidator.cs
- SystemFonts.cs
- ADConnectionHelper.cs
- UnsafeNativeMethods.cs
- GridItem.cs
- WinFormsComponentEditor.cs
- UrlMapping.cs
- _CookieModule.cs
- DependencyPropertyDescriptor.cs
- SurrogateEncoder.cs
- RepeatInfo.cs
- CodeAttributeArgument.cs
- MultipartContentParser.cs
- WindowsListView.cs
- GroupItemAutomationPeer.cs
- FrameworkTextComposition.cs
- OdbcCommandBuilder.cs
- TransactionContextValidator.cs
- XmlSerializerFactory.cs
- DispatcherObject.cs
- VoiceSynthesis.cs
- EntityContainerEmitter.cs
- SystemTcpStatistics.cs
- TriggerActionCollection.cs
- Int16Converter.cs
- mediaeventargs.cs
- XsdBuilder.cs
- CodeDomDesignerLoader.cs
- KnownColorTable.cs
- ToolStripPanelRenderEventArgs.cs
- ConfigurationSectionCollection.cs
- BrowserDefinition.cs
- DataGridDetailsPresenterAutomationPeer.cs
- ResponseBodyWriter.cs
- RemoteArgument.cs
- ThicknessKeyFrameCollection.cs
- DataGridHelper.cs
- ClientScriptItem.cs
- OleDbDataReader.cs
- FieldToken.cs
- AmbientValueAttribute.cs
- EntityDataSourceSelectedEventArgs.cs
- MultiPropertyDescriptorGridEntry.cs
- MembershipPasswordException.cs
- ServiceOperationInvoker.cs
- VisualStateGroup.cs
- ProcessRequestArgs.cs
- MessageSecurityOverHttpElement.cs
- LinkUtilities.cs
- WindowsClaimSet.cs
- UrlMapping.cs
- EdmTypeAttribute.cs
- XmlEventCache.cs
- DeferredTextReference.cs
- ConvertersCollection.cs
- AssemblyCollection.cs
- IImplicitResourceProvider.cs
- ApplicationProxyInternal.cs
- InputElement.cs
- LabelDesigner.cs
- IResourceProvider.cs
- TreeIterator.cs
- DurationConverter.cs
- StaticSiteMapProvider.cs
- ObjectPersistData.cs
- GridViewRowCollection.cs
- HttpContextServiceHost.cs
- SchemaSetCompiler.cs