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 EnumerableRowCollection Where(
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 OrderedEnumerableRowCollection OrderBy(
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 OrderedEnumerableRowCollection OrderBy(
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 OrderedEnumerableRowCollection OrderByDescending(
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 OrderedEnumerableRowCollection OrderByDescending(
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 EnumerableRowCollection Select(
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 EnumerableRowCollection AsEnumerable(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 EnumerableRowCollection Where(
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 OrderedEnumerableRowCollection OrderBy(
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 OrderedEnumerableRowCollection OrderBy(
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 OrderedEnumerableRowCollection OrderByDescending(
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 OrderedEnumerableRowCollection OrderByDescending(
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 EnumerableRowCollection Select(
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 EnumerableRowCollection AsEnumerable(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
- TextBox.cs
- DataControlFieldCell.cs
- NetCodeGroup.cs
- Axis.cs
- MultiByteCodec.cs
- BufferModesCollection.cs
- SoapServerMessage.cs
- PublisherIdentityPermission.cs
- InheritanceRules.cs
- ManagedWndProcTracker.cs
- ImageBrush.cs
- TextServicesLoader.cs
- ExpressionParser.cs
- RTLAwareMessageBox.cs
- JapaneseLunisolarCalendar.cs
- PeerNameRecordCollection.cs
- DataObjectCopyingEventArgs.cs
- NotifyIcon.cs
- BindingUtils.cs
- CertificateReferenceElement.cs
- AddInPipelineAttributes.cs
- BindValidator.cs
- TextBreakpoint.cs
- SafeNativeMethods.cs
- cookie.cs
- backend.cs
- RunInstallerAttribute.cs
- mediapermission.cs
- DesignerForm.cs
- ELinqQueryState.cs
- ProtocolViolationException.cs
- FormatConvertedBitmap.cs
- OutputCacheModule.cs
- EntityContainer.cs
- StringHelper.cs
- ContextStack.cs
- StorageScalarPropertyMapping.cs
- NamespaceEmitter.cs
- PeerResolverElement.cs
- Parser.cs
- ApplicationId.cs
- Html32TextWriter.cs
- DataGridViewRowStateChangedEventArgs.cs
- HMACSHA384.cs
- XmlNamespaceManager.cs
- LogSwitch.cs
- FormsAuthentication.cs
- DbXmlEnabledProviderManifest.cs
- SchemaDeclBase.cs
- XmlnsCache.cs
- PixelFormatConverter.cs
- SerializationAttributes.cs
- Model3D.cs
- Utility.cs
- NonBatchDirectoryCompiler.cs
- AsyncPostBackTrigger.cs
- CustomAttribute.cs
- TableRowCollection.cs
- SudsParser.cs
- TypeConverter.cs
- DataGridDesigner.cs
- Label.cs
- DataGridView.cs
- UnsupportedPolicyOptionsException.cs
- RelationshipConverter.cs
- ContainerParagraph.cs
- InitializerFacet.cs
- WebServiceTypeData.cs
- NamespaceTable.cs
- Compiler.cs
- ParameterElementCollection.cs
- ReliableChannelFactory.cs
- updateconfighost.cs
- Utils.cs
- WorkItem.cs
- WindowsUpDown.cs
- NonVisualControlAttribute.cs
- AffineTransform3D.cs
- CustomAttributeBuilder.cs
- TemplateBindingExpression.cs
- TargetException.cs
- NamespaceInfo.cs
- XPathMessageContext.cs
- QueryResults.cs
- Size.cs
- WorkflowDebuggerSteppingAttribute.cs
- X509ChainElement.cs
- InternalMappingException.cs
- LocalValueEnumerator.cs
- FrameworkContextData.cs
- ManagedWndProcTracker.cs
- SafeFindHandle.cs
- PersistenceTypeAttribute.cs
- ThreadPool.cs
- EncoderBestFitFallback.cs
- DataGridViewRow.cs
- SessionIDManager.cs
- ClearCollection.cs
- Transform3DGroup.cs
- ToolBar.cs