Code:
/ 4.0 / 4.0 / 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
- MsmqIntegrationReceiveParameters.cs
- TableDetailsRow.cs
- ExpressionEditor.cs
- OLEDB_Util.cs
- GlyphManager.cs
- PrinterUnitConvert.cs
- MultiSelector.cs
- IpcManager.cs
- Pen.cs
- OleDbDataReader.cs
- AmbientEnvironment.cs
- NameValuePair.cs
- FormViewRow.cs
- querybuilder.cs
- WorkflowElementDialogWindow.xaml.cs
- ITextView.cs
- EdmComplexPropertyAttribute.cs
- InfoCardProofToken.cs
- DeploymentSection.cs
- StringOutput.cs
- ExpressionPrefixAttribute.cs
- TraceSource.cs
- BaseTemplateBuildProvider.cs
- ImplicitInputBrush.cs
- RuleProcessor.cs
- wgx_sdk_version.cs
- XmlSchemaSimpleContent.cs
- _ListenerRequestStream.cs
- AutomationIdentifier.cs
- ColorTransform.cs
- InternalBufferOverflowException.cs
- SymDocumentType.cs
- GeometryGroup.cs
- CachedFontFamily.cs
- PhonemeEventArgs.cs
- RoleManagerEventArgs.cs
- TreeNodeStyleCollectionEditor.cs
- webproxy.cs
- Registration.cs
- XmlSchemaDocumentation.cs
- CodeDefaultValueExpression.cs
- TripleDESCryptoServiceProvider.cs
- MemoryFailPoint.cs
- ValidationSummary.cs
- AttachmentService.cs
- SplitterEvent.cs
- CompoundFileStorageReference.cs
- SvcMapFileLoader.cs
- PermissionListSet.cs
- DataGridAutoFormatDialog.cs
- ActiveXHelper.cs
- CacheMemory.cs
- ButtonColumn.cs
- __FastResourceComparer.cs
- SrgsElementFactoryCompiler.cs
- FileChangeNotifier.cs
- CompiledRegexRunnerFactory.cs
- DataGridViewCellStyleConverter.cs
- ZipPackage.cs
- COM2ColorConverter.cs
- Soap.cs
- DataTableTypeConverter.cs
- XslTransform.cs
- Int64.cs
- ParserContext.cs
- FixedTextContainer.cs
- DocumentReferenceCollection.cs
- RawStylusInputCustomDataList.cs
- HttpRawResponse.cs
- _ConnectStream.cs
- ErrorsHelper.cs
- pingexception.cs
- ItemContainerGenerator.cs
- AdRotatorDesigner.cs
- ClientRuntimeConfig.cs
- DbXmlEnabledProviderManifest.cs
- EntryIndex.cs
- IProducerConsumerCollection.cs
- ConnectionPoolRegistry.cs
- SystemIcons.cs
- SqlRowUpdatingEvent.cs
- BackStopAuthenticationModule.cs
- _StreamFramer.cs
- ComponentResourceKeyConverter.cs
- NotFiniteNumberException.cs
- XmlSchemaInclude.cs
- OdbcCommand.cs
- _NetworkingPerfCounters.cs
- SQLInt16.cs
- ScaleTransform3D.cs
- FilePrompt.cs
- MediaPlayer.cs
- ServerValidateEventArgs.cs
- ProjectionCamera.cs
- TaskHelper.cs
- HtmlHead.cs
- CompModSwitches.cs
- EncryptedPackageFilter.cs
- UInt32Converter.cs
- PopOutPanel.cs