Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataSet / System / Data / DataRowExtensions.cs / 1305376 / DataRowExtensions.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //spather //----------------------------------------------------------------------------- using System; using System.Data.DataSetExtensions; namespace System.Data { ////// This static class defines the DataRow extension methods. /// public static class DataRowExtensions { ////// This method provides access to the values in each of the columns in a given row. /// This method makes casts unnecessary when accessing columns. /// Additionally, Field supports nullable types and maps automatically between DBNull and /// Nullable when the generic type is nullable. /// /// /// The input DataRow /// /// /// The input column name specificy which row value to retrieve. /// ////// The DataRow value for the column specified. /// public static T Field(this DataRow row, string columnName) { DataSetUtil.CheckArgumentNull(row, "row"); return UnboxT .Unbox(row[columnName]); } /// /// This method provides access to the values in each of the columns in a given row. /// This method makes casts unnecessary when accessing columns. /// Additionally, Field supports nullable types and maps automatically between DBNull and /// Nullable when the generic type is nullable. /// /// /// The input DataRow /// /// /// The input DataColumn specificy which row value to retrieve. /// ////// The DataRow value for the column specified. /// public static T Field(this DataRow row, DataColumn column) { DataSetUtil.CheckArgumentNull(row, "row"); return UnboxT .Unbox(row[column]); } /// /// This method provides access to the values in each of the columns in a given row. /// This method makes casts unnecessary when accessing columns. /// Additionally, Field supports nullable types and maps automatically between DBNull and /// Nullable when the generic type is nullable. /// /// /// The input DataRow /// /// /// The input ordinal specificy which row value to retrieve. /// ////// The DataRow value for the column specified. /// public static T Field(this DataRow row, int columnIndex) { DataSetUtil.CheckArgumentNull(row, "row"); return UnboxT .Unbox(row[columnIndex]); } /// /// This method provides access to the values in each of the columns in a given row. /// This method makes casts unnecessary when accessing columns. /// Additionally, Field supports nullable types and maps automatically between DBNull and /// Nullable when the generic type is nullable. /// /// /// The input DataRow /// /// /// The input ordinal specificy which row value to retrieve. /// /// /// The DataRow version for which row value to retrieve. /// ////// The DataRow value for the column specified. /// public static T Field(this DataRow row, int columnIndex, DataRowVersion version) { DataSetUtil.CheckArgumentNull(row, "row"); return UnboxT .Unbox(row[columnIndex, version]); } /// /// This method provides access to the values in each of the columns in a given row. /// This method makes casts unnecessary when accessing columns. /// Additionally, Field supports nullable types and maps automatically between DBNull and /// Nullable when the generic type is nullable. /// /// /// The input DataRow /// /// /// The input column name specificy which row value to retrieve. /// /// /// The DataRow version for which row value to retrieve. /// ////// The DataRow value for the column specified. /// public static T Field(this DataRow row, string columnName, DataRowVersion version) { DataSetUtil.CheckArgumentNull(row, "row"); return UnboxT .Unbox(row[columnName, version]); } /// /// This method provides access to the values in each of the columns in a given row. /// This method makes casts unnecessary when accessing columns. /// Additionally, Field supports nullable types and maps automatically between DBNull and /// Nullable when the generic type is nullable. /// /// /// The input DataRow /// /// /// The input DataColumn specificy which row value to retrieve. /// /// /// The DataRow version for which row value to retrieve. /// ////// The DataRow value for the column specified. /// public static T Field(this DataRow row, DataColumn column, DataRowVersion version) { DataSetUtil.CheckArgumentNull(row, "row"); return UnboxT .Unbox(row[column, version]); } /// /// This method sets a new value for the specified column for the DataRow it�s called on. /// /// /// The input DataRow. /// /// /// The input ordinal specifying which row value to set. /// /// /// The new row value for the specified column. /// public static void SetField(this DataRow row, int columnIndex, T value) { DataSetUtil.CheckArgumentNull(row, "row"); row[columnIndex] = (object)value ?? DBNull.Value; } /// /// This method sets a new value for the specified column for the DataRow it�s called on. /// /// /// The input DataRow. /// /// /// The input column name specificy which row value to retrieve. /// /// /// The new row value for the specified column. /// public static void SetField(this DataRow row, string columnName, T value) { DataSetUtil.CheckArgumentNull(row, "row"); row[columnName] = (object)value ?? DBNull.Value; } /// /// This method sets a new value for the specified column for the DataRow it�s called on. /// /// /// The input DataRow. /// /// /// The input DataColumn specificy which row value to retrieve. /// /// /// The new row value for the specified column. /// public static void SetField(this DataRow row, DataColumn column, T value) { DataSetUtil.CheckArgumentNull(row, "row"); row[column] = (object)value ?? DBNull.Value; } private static class UnboxT { internal static readonly Converter
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SystemPens.cs
- ipaddressinformationcollection.cs
- WebPartPersonalization.cs
- CqlBlock.cs
- PropertyValueUIItem.cs
- Misc.cs
- BehaviorDragDropEventArgs.cs
- ProxyFragment.cs
- ElementUtil.cs
- SiteMapNode.cs
- UrlMappingsModule.cs
- ViewBase.cs
- TraceUtils.cs
- SolidColorBrush.cs
- MetadataPropertyvalue.cs
- BlurBitmapEffect.cs
- DomainUpDown.cs
- CLRBindingWorker.cs
- SslSecurityTokenParameters.cs
- Maps.cs
- EdgeProfileValidation.cs
- X509CertificateCollection.cs
- DataGridViewComboBoxColumn.cs
- DataGridHelper.cs
- AVElementHelper.cs
- FrameworkElement.cs
- Function.cs
- WindowInteropHelper.cs
- BinHexEncoder.cs
- PlacementWorkspace.cs
- PageEventArgs.cs
- DataSourceCache.cs
- sqlstateclientmanager.cs
- EdmToObjectNamespaceMap.cs
- DataServiceClientException.cs
- SafeUserTokenHandle.cs
- NativeMethods.cs
- EventLog.cs
- AccessDataSourceView.cs
- CallbackHandler.cs
- DriveInfo.cs
- XPathChildIterator.cs
- XmlSchemaType.cs
- ParameterModifier.cs
- Transaction.cs
- TemplateNodeContextMenu.cs
- GeneralTransform2DTo3DTo2D.cs
- UIPermission.cs
- ParallelDesigner.xaml.cs
- WsatServiceAddress.cs
- HttpCookieCollection.cs
- SmtpFailedRecipientException.cs
- SmtpFailedRecipientsException.cs
- ParentQuery.cs
- ScrollEvent.cs
- ToolStripItemEventArgs.cs
- ViewStateException.cs
- FieldBuilder.cs
- PolicyImporterElementCollection.cs
- ImpersonateTokenRef.cs
- ComplexTypeEmitter.cs
- BamlBinaryReader.cs
- CodeNamespaceCollection.cs
- SiteIdentityPermission.cs
- ItemDragEvent.cs
- XmlSecureResolver.cs
- EntityViewContainer.cs
- XmlLoader.cs
- DefaultProxySection.cs
- ProxySimple.cs
- xmlformatgeneratorstatics.cs
- NullableFloatSumAggregationOperator.cs
- DataSourceCacheDurationConverter.cs
- PartialCachingControl.cs
- QueryContinueDragEventArgs.cs
- LoaderAllocator.cs
- MobileUserControlDesigner.cs
- Point4D.cs
- ObjectFullSpanRewriter.cs
- SocketManager.cs
- ScriptResourceInfo.cs
- BindingList.cs
- OdbcParameterCollection.cs
- DataException.cs
- VisualBasicValue.cs
- TraceXPathNavigator.cs
- SctClaimDictionary.cs
- ClosableStream.cs
- VideoDrawing.cs
- DataSourceCache.cs
- ReferencedType.cs
- Baml2006KnownTypes.cs
- CodeAssignStatement.cs
- DataGridCellInfo.cs
- StoreItemCollection.cs
- DispatcherTimer.cs
- ItemsChangedEventArgs.cs
- KnownBoxes.cs
- PropertyMapper.cs
- HostingEnvironmentSection.cs