Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- BaseCollection.cs
- OdbcRowUpdatingEvent.cs
- XPathQueryGenerator.cs
- NamespaceDecl.cs
- PageContent.cs
- TypeLoadException.cs
- DataGridViewDataErrorEventArgs.cs
- TypeUsageBuilder.cs
- GeneratedContractType.cs
- ObjectCloneHelper.cs
- MappingModelBuildProvider.cs
- DataGridViewCheckBoxCell.cs
- FrameSecurityDescriptor.cs
- infer.cs
- WorkflowDispatchContext.cs
- ElementHost.cs
- DateTimeConverter.cs
- MSAANativeProvider.cs
- ProjectionCamera.cs
- FlowLayoutPanel.cs
- EventsTab.cs
- XmlDocumentSerializer.cs
- PointAnimationClockResource.cs
- RulePatternOps.cs
- WebPartManagerInternals.cs
- SmtpTransport.cs
- CompilerParameters.cs
- TextTrailingWordEllipsis.cs
- PointValueSerializer.cs
- ApplicationDirectory.cs
- MessageBox.cs
- EditingContext.cs
- Geometry.cs
- SourceSwitch.cs
- ParseChildrenAsPropertiesAttribute.cs
- MetadataFile.cs
- ResourcePermissionBase.cs
- JulianCalendar.cs
- ScriptMethodAttribute.cs
- LookupTables.cs
- ClientUrlResolverWrapper.cs
- WindowPattern.cs
- CodeDirectoryCompiler.cs
- PageParser.cs
- ModifierKeysConverter.cs
- ExceptionUtil.cs
- GlyphRunDrawing.cs
- GenericRootAutomationPeer.cs
- SoapAttributeAttribute.cs
- MsmqIntegrationBindingElement.cs
- Decimal.cs
- MexTcpBindingCollectionElement.cs
- ObjectSerializerFactory.cs
- SchemaNotation.cs
- AnnotationAuthorChangedEventArgs.cs
- TraceRecord.cs
- TextTabProperties.cs
- ZipArchive.cs
- WorkerRequest.cs
- SafeNativeMethods.cs
- InputScope.cs
- HtmlToClrEventProxy.cs
- NativeMethods.cs
- BuildProvidersCompiler.cs
- ActivityExecutor.cs
- DefaultValueConverter.cs
- UidManager.cs
- CornerRadiusConverter.cs
- SqlDeflator.cs
- Rule.cs
- DataGridViewTextBoxCell.cs
- ConstructorNeedsTagAttribute.cs
- ObjectHandle.cs
- FullTrustAssemblyCollection.cs
- VisualBasic.cs
- FormsAuthentication.cs
- ErrorHandler.cs
- TranslateTransform3D.cs
- ChangeToolStripParentVerb.cs
- DrawingContextDrawingContextWalker.cs
- StronglyTypedResourceBuilder.cs
- VolatileResourceManager.cs
- StylusPointPropertyInfoDefaults.cs
- FolderLevelBuildProviderAppliesToAttribute.cs
- PreservationFileReader.cs
- BitmapDecoder.cs
- GetBrowserTokenRequest.cs
- CompilerHelpers.cs
- OracleLob.cs
- Utils.cs
- HiddenFieldDesigner.cs
- DataGridViewCellCollection.cs
- MessageEventSubscriptionService.cs
- Viewport3DVisual.cs
- SQLRoleProvider.cs
- SendContent.cs
- ObjectItemLoadingSessionData.cs
- Size3DValueSerializer.cs
- DataGridGeneralPage.cs
- Deflater.cs