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
- LoginView.cs
- WebRequestModulesSection.cs
- StringStorage.cs
- ProviderConnectionPoint.cs
- RenderContext.cs
- ToggleButtonAutomationPeer.cs
- EdgeProfileValidation.cs
- SqlStream.cs
- ThrowHelper.cs
- RadioButton.cs
- ProfileWorkflowElement.cs
- MouseButtonEventArgs.cs
- ContractComponent.cs
- XmlC14NWriter.cs
- DefaultShape.cs
- StorageConditionPropertyMapping.cs
- UIPropertyMetadata.cs
- ImageButton.cs
- SQLSingleStorage.cs
- ToolStripSplitButton.cs
- XmlLinkedNode.cs
- SettingsBindableAttribute.cs
- ExecutionContext.cs
- TransactionProxy.cs
- XmlSiteMapProvider.cs
- DataStreams.cs
- TextRunTypographyProperties.cs
- ManagedFilter.cs
- KeyedHashAlgorithm.cs
- CoTaskMemHandle.cs
- ComponentSerializationService.cs
- dbdatarecord.cs
- ExternalFile.cs
- BufferedOutputStream.cs
- WorkflowClientDeliverMessageWrapper.cs
- XmlUnspecifiedAttribute.cs
- DataGrid.cs
- Pointer.cs
- JavaScriptString.cs
- BinaryFormatter.cs
- HitTestWithPointDrawingContextWalker.cs
- MsmqDiagnostics.cs
- TransactionsSectionGroup.cs
- DiscoveryOperationContext.cs
- HttpInputStream.cs
- Misc.cs
- TypeRestriction.cs
- SqlDataReaderSmi.cs
- DocumentSchemaValidator.cs
- CommunicationObjectFaultedException.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- PartialCachingAttribute.cs
- DBDataPermission.cs
- input.cs
- Rect.cs
- HttpGetServerProtocol.cs
- Classification.cs
- CriticalFinalizerObject.cs
- ViewPort3D.cs
- GridViewDeletedEventArgs.cs
- PrintDialog.cs
- PnrpPeerResolverBindingElement.cs
- QueuedDeliveryRequirementsMode.cs
- TextEditorDragDrop.cs
- SHA512Managed.cs
- EntityParameter.cs
- LineServicesRun.cs
- FormatterConverter.cs
- EmptyEnumerator.cs
- ITextView.cs
- DiagnosticTraceSource.cs
- StatusBar.cs
- TextEditorThreadLocalStore.cs
- RangeValuePatternIdentifiers.cs
- DocumentPaginator.cs
- SystemIPGlobalProperties.cs
- ListDictionary.cs
- sitestring.cs
- DocumentPageViewAutomationPeer.cs
- CategoryNameCollection.cs
- CodeDirectionExpression.cs
- ListBindableAttribute.cs
- WorkflowInstance.cs
- HostedTransportConfigurationBase.cs
- WebPartManagerInternals.cs
- MaskedTextBoxTextEditorDropDown.cs
- ReachUIElementCollectionSerializerAsync.cs
- OracleParameterBinding.cs
- UInt32.cs
- OdbcConnectionStringbuilder.cs
- StreamUpdate.cs
- CheckBoxBaseAdapter.cs
- HierarchicalDataBoundControlAdapter.cs
- DbProviderSpecificTypePropertyAttribute.cs
- DataGrid.cs
- XmlSignatureProperties.cs
- RuleSettings.cs
- WebPartManagerInternals.cs
- HexParser.cs
- UiaCoreApi.cs