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
- ExpressionCopier.cs
- CreateUserWizard.cs
- RelatedPropertyManager.cs
- URI.cs
- FormViewPageEventArgs.cs
- PowerEase.cs
- EntryWrittenEventArgs.cs
- UpdateManifestForBrowserApplication.cs
- LifetimeServices.cs
- PermissionSet.cs
- Utils.cs
- Internal.cs
- DiffuseMaterial.cs
- _CommandStream.cs
- FormViewUpdateEventArgs.cs
- FrameworkElementAutomationPeer.cs
- CodeDomDesignerLoader.cs
- WindowsAuthenticationModule.cs
- ReaderWriterLockWrapper.cs
- SqlCacheDependencySection.cs
- RankException.cs
- ThreadStateException.cs
- ListQueryResults.cs
- PriorityBinding.cs
- WindowsListViewItem.cs
- InfoCardUIAgent.cs
- SortKey.cs
- BitmapData.cs
- AutomationProperties.cs
- CachedPathData.cs
- TextServicesProperty.cs
- CodeParameterDeclarationExpressionCollection.cs
- SecurityTokenProviderContainer.cs
- CssTextWriter.cs
- WebPartMenu.cs
- XamlStackWriter.cs
- TextTrailingWordEllipsis.cs
- ClientUrlResolverWrapper.cs
- TreeSet.cs
- SqlServices.cs
- VisualStyleInformation.cs
- DataPagerFieldItem.cs
- RtfToken.cs
- SqlPersonalizationProvider.cs
- OperandQuery.cs
- DbConnectionPoolCounters.cs
- TcpChannelHelper.cs
- Attributes.cs
- PowerStatus.cs
- DisplayInformation.cs
- XmlSchemaCollection.cs
- ColorConvertedBitmapExtension.cs
- WorkflowApplicationCompletedException.cs
- ClientRuntimeConfig.cs
- SerializationStore.cs
- NamespaceList.cs
- HandlerFactoryCache.cs
- PointKeyFrameCollection.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- HttpPostedFile.cs
- FormViewDesigner.cs
- TCPListener.cs
- XmlHierarchicalDataSourceView.cs
- SqlWebEventProvider.cs
- DataPagerFieldCommandEventArgs.cs
- OpenFileDialog.cs
- GeneralTransform3D.cs
- WasAdminWrapper.cs
- CryptoApi.cs
- NameValueCollection.cs
- ObjectSpanRewriter.cs
- DbCommandDefinition.cs
- Utils.cs
- ListViewAutomationPeer.cs
- Helpers.cs
- ColumnWidthChangingEvent.cs
- WS2007FederationHttpBindingElement.cs
- Attributes.cs
- TextPatternIdentifiers.cs
- _AcceptOverlappedAsyncResult.cs
- SecurityDescriptor.cs
- DbCommandDefinition.cs
- ContextMenu.cs
- FastPropertyAccessor.cs
- SamlAssertionKeyIdentifierClause.cs
- PropertyGridView.cs
- BindingBase.cs
- SqlDataSourceCustomCommandPanel.cs
- xmlglyphRunInfo.cs
- FixedFindEngine.cs
- SpotLight.cs
- ToolStripHighContrastRenderer.cs
- Exceptions.cs
- ParseChildrenAsPropertiesAttribute.cs
- InvokeSchedule.cs
- FixUpCollection.cs
- DateTimeFormatInfoScanner.cs
- SymLanguageVendor.cs
- TextViewBase.cs
- RawMouseInputReport.cs