Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- Calendar.cs
- ToolStripScrollButton.cs
- EventWaitHandle.cs
- CopyAttributesAction.cs
- SecurityUtils.cs
- KeyEventArgs.cs
- AstTree.cs
- MaskedTextBoxTextEditorDropDown.cs
- TreeView.cs
- SQLDecimalStorage.cs
- OutKeywords.cs
- InlineObject.cs
- Policy.cs
- Matrix3DValueSerializer.cs
- SecurityKeyIdentifierClause.cs
- Baml6ConstructorInfo.cs
- TdsParserStateObject.cs
- SelectedDatesCollection.cs
- _ConnectOverlappedAsyncResult.cs
- SchemaNamespaceManager.cs
- DataTemplateKey.cs
- BatchWriter.cs
- TextRange.cs
- CodeGotoStatement.cs
- keycontainerpermission.cs
- TrustLevel.cs
- AbandonedMutexException.cs
- ProbeDuplexAsyncResult.cs
- WinFormsComponentEditor.cs
- DateTimeAutomationPeer.cs
- LineMetrics.cs
- BinarySecretKeyIdentifierClause.cs
- ObjectTypeMapping.cs
- IdentityNotMappedException.cs
- ExpandedWrapper.cs
- HtmlInputText.cs
- MethodAccessException.cs
- WebPartHelpVerb.cs
- MetadataItem.cs
- WorkflowMarkupElementEventArgs.cs
- PrintPreviewGraphics.cs
- ContentAlignmentEditor.cs
- StateManagedCollection.cs
- XPathBinder.cs
- HandlerMappingMemo.cs
- ZipIOFileItemStream.cs
- DocumentReference.cs
- DispatcherExceptionEventArgs.cs
- VisualTreeUtils.cs
- WizardPanelChangingEventArgs.cs
- WindowsGraphicsCacheManager.cs
- IIS7WorkerRequest.cs
- XmlBinaryWriter.cs
- ExpressionVisitor.cs
- HelpHtmlBuilder.cs
- TreeNodeCollection.cs
- SerializationAttributes.cs
- BooleanToVisibilityConverter.cs
- PanelDesigner.cs
- SaveFileDialog.cs
- SqlBulkCopyColumnMapping.cs
- processwaithandle.cs
- Regex.cs
- NativeMethods.cs
- ClassHandlersStore.cs
- SmtpReplyReader.cs
- SqlRewriteScalarSubqueries.cs
- DispatcherEventArgs.cs
- ToolStripScrollButton.cs
- Internal.cs
- RectAnimationUsingKeyFrames.cs
- TraceContextEventArgs.cs
- SerializableAuthorizationContext.cs
- OleServicesContext.cs
- TextDocumentView.cs
- CodeFieldReferenceExpression.cs
- AssemblyAssociatedContentFileAttribute.cs
- WorkflowShape.cs
- SqlVisitor.cs
- RepeatBehavior.cs
- BindingExpression.cs
- DataPointer.cs
- JapaneseLunisolarCalendar.cs
- PageCatalogPart.cs
- ReflectTypeDescriptionProvider.cs
- AmbientProperties.cs
- XmlCollation.cs
- NamedPipeConnectionPool.cs
- AgileSafeNativeMemoryHandle.cs
- Rule.cs
- ClientSideQueueItem.cs
- SchemaReference.cs
- CompositeActivityMarkupSerializer.cs
- ThemeableAttribute.cs
- BoolLiteral.cs
- FamilyMap.cs
- linebase.cs
- CultureData.cs
- BuildManagerHost.cs
- CodeTypeDelegate.cs