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 / DataRowExtensions.cs / 1 / 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
- FlowDocumentView.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- WaitHandle.cs
- FocusManager.cs
- BrowserTree.cs
- RootDesignerSerializerAttribute.cs
- Membership.cs
- MouseGestureConverter.cs
- ApplicationSettingsBase.cs
- OledbConnectionStringbuilder.cs
- PageAsyncTask.cs
- PointCollectionConverter.cs
- DetailsViewDeleteEventArgs.cs
- CustomAttributeBuilder.cs
- Timer.cs
- SmiTypedGetterSetter.cs
- TextTreeUndoUnit.cs
- TableItemStyle.cs
- WindowsFormsDesignerOptionService.cs
- WindowProviderWrapper.cs
- XPathChildIterator.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- FlowDocumentFormatter.cs
- DataBindingHandlerAttribute.cs
- Random.cs
- DrawingGroup.cs
- StagingAreaInputItem.cs
- DataGridViewComboBoxColumn.cs
- OletxDependentTransaction.cs
- SqlColumnizer.cs
- Query.cs
- EdmComplexTypeAttribute.cs
- ExtensionWindowResizeGrip.cs
- TransformPatternIdentifiers.cs
- TextChangedEventArgs.cs
- FixedTextContainer.cs
- StylusShape.cs
- StrokeFIndices.cs
- GridViewColumnCollection.cs
- FlatButtonAppearance.cs
- WindowsFormsHostPropertyMap.cs
- ColorAnimationUsingKeyFrames.cs
- DockPatternIdentifiers.cs
- Walker.cs
- CodeNamespaceCollection.cs
- MimeTextImporter.cs
- PolicyException.cs
- InstanceDataCollectionCollection.cs
- MappingModelBuildProvider.cs
- CodeGeneratorOptions.cs
- ListenerElementsCollection.cs
- DataBindingCollection.cs
- Error.cs
- RunWorkerCompletedEventArgs.cs
- Types.cs
- HashAlgorithm.cs
- Label.cs
- Monitor.cs
- TargetControlTypeAttribute.cs
- CaseInsensitiveHashCodeProvider.cs
- DoubleIndependentAnimationStorage.cs
- ScriptControl.cs
- OdbcDataAdapter.cs
- DataAccessor.cs
- MenuItem.cs
- FormViewUpdateEventArgs.cs
- DbConnectionInternal.cs
- QilTargetType.cs
- ArgumentNullException.cs
- EncryptedData.cs
- GlobalizationAssembly.cs
- ButtonPopupAdapter.cs
- FirstMatchCodeGroup.cs
- MatrixCamera.cs
- XmlSerializerFactory.cs
- StateManagedCollection.cs
- IPGlobalProperties.cs
- SplitterEvent.cs
- HttpServerUtilityWrapper.cs
- Bits.cs
- ProfileServiceManager.cs
- FontFamily.cs
- ConnectionProviderAttribute.cs
- ControlParameter.cs
- InkCanvasSelection.cs
- VolatileEnlistmentMultiplexing.cs
- CursorConverter.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- FileIOPermission.cs
- XmlSchemaInferenceException.cs
- Console.cs
- BaseTreeIterator.cs
- CodeParameterDeclarationExpression.cs
- ListView.cs
- ProviderSettings.cs
- ConnectionsZoneAutoFormat.cs
- DataGridView.cs
- CacheSection.cs
- DesignerActionUIService.cs
- MultiDataTrigger.cs