Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- TransformerInfo.cs
- LockRenewalTask.cs
- GridViewColumnHeader.cs
- DataReceivedEventArgs.cs
- COAUTHIDENTITY.cs
- FixedSOMFixedBlock.cs
- FormsAuthenticationCredentials.cs
- AsyncResult.cs
- ClientSideProviderDescription.cs
- SqlFactory.cs
- DataKeyArray.cs
- SearchForVirtualItemEventArgs.cs
- WindowsRebar.cs
- PackagePartCollection.cs
- WindowsListViewItemStartMenu.cs
- cookieexception.cs
- WindowsEditBox.cs
- Fx.cs
- TextEditorCopyPaste.cs
- SelectionRangeConverter.cs
- TaskFileService.cs
- FileEnumerator.cs
- Visual3D.cs
- C14NUtil.cs
- TextPenaltyModule.cs
- CalendarTable.cs
- RestHandler.cs
- DateTimeParse.cs
- DebugView.cs
- X509Certificate.cs
- QueryCacheKey.cs
- StyleHelper.cs
- HierarchicalDataBoundControl.cs
- DataGridViewControlCollection.cs
- FocusWithinProperty.cs
- PageSetupDialog.cs
- WindowsListBox.cs
- ChildChangedEventArgs.cs
- NetWebProxyFinder.cs
- TextElement.cs
- _Events.cs
- RootAction.cs
- _RequestCacheProtocol.cs
- CounterCreationDataCollection.cs
- GeometryDrawing.cs
- EntityDataSourceDesigner.cs
- BitmapImage.cs
- ISAPIApplicationHost.cs
- ConfigXmlAttribute.cs
- FileDialogPermission.cs
- CommandID.cs
- PeerCollaboration.cs
- ObjectToIdCache.cs
- SelectionProcessor.cs
- StringConverter.cs
- LineInfo.cs
- HttpGetProtocolReflector.cs
- Triangle.cs
- Pkcs7Signer.cs
- SchemaNotation.cs
- SpecialFolderEnumConverter.cs
- DomainConstraint.cs
- BitmapEffectGeneralTransform.cs
- Stacktrace.cs
- ResourceProperty.cs
- SByte.cs
- StrokeFIndices.cs
- Point3DConverter.cs
- ReadOnlyHierarchicalDataSource.cs
- sqlpipe.cs
- EntityTypeEmitter.cs
- DoubleLink.cs
- SvcMapFileSerializer.cs
- ClientRoleProvider.cs
- WebPartMenuStyle.cs
- ContractMethodInfo.cs
- TextContainerChangedEventArgs.cs
- ServiceDescriptions.cs
- AmbientLight.cs
- ProcessModuleCollection.cs
- BinaryUtilClasses.cs
- Memoizer.cs
- XmlSchemaImporter.cs
- PartialCachingAttribute.cs
- ConnectionManagementElementCollection.cs
- ProtocolsConfiguration.cs
- MenuAutomationPeer.cs
- StatusBarPanelClickEvent.cs
- XmlILCommand.cs
- CellRelation.cs
- coordinatorscratchpad.cs
- SafeCloseHandleCritical.cs
- WpfPayload.cs
- ConfigurationProperty.cs
- CorrelationManager.cs
- InputLanguageEventArgs.cs
- SnapLine.cs
- RequestNavigateEventArgs.cs
- LayoutTable.cs
- RadioButtonBaseAdapter.cs