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
- AspNetSynchronizationContext.cs
- StringArrayConverter.cs
- EdmItemCollection.cs
- StrongNameUtility.cs
- CqlLexerHelpers.cs
- UTF8Encoding.cs
- SoapIncludeAttribute.cs
- ExecutionContext.cs
- FontResourceCache.cs
- WmiEventSink.cs
- DecoderFallback.cs
- FrameworkReadOnlyPropertyMetadata.cs
- TextParentUndoUnit.cs
- XamlToRtfWriter.cs
- Number.cs
- SqlDataSourceSelectingEventArgs.cs
- CompositeControl.cs
- SelectionWordBreaker.cs
- ExceptionUtil.cs
- XmlSiteMapProvider.cs
- ListSortDescriptionCollection.cs
- RegexMatch.cs
- MustUnderstandSoapException.cs
- CornerRadiusConverter.cs
- TypedAsyncResult.cs
- SettingsBindableAttribute.cs
- TreeNode.cs
- HMAC.cs
- HttpCacheVary.cs
- ISCIIEncoding.cs
- ForEachAction.cs
- _StreamFramer.cs
- CatalogPartChrome.cs
- HttpCapabilitiesBase.cs
- ExtractedStateEntry.cs
- EdmItemCollection.OcAssemblyCache.cs
- ConfigUtil.cs
- DataReceivedEventArgs.cs
- SpecialFolderEnumConverter.cs
- GridViewPageEventArgs.cs
- LinkConverter.cs
- RegisteredScript.cs
- ToolStripContainer.cs
- DataServiceBuildProvider.cs
- TransformCryptoHandle.cs
- AccessDataSourceView.cs
- VisualStyleInformation.cs
- MenuItemBindingCollection.cs
- RadioButton.cs
- SafeHandle.cs
- Emitter.cs
- OciEnlistContext.cs
- ConfigurationProperty.cs
- ArgIterator.cs
- SoapMessage.cs
- NotImplementedException.cs
- CheckBoxPopupAdapter.cs
- ControlAdapter.cs
- NumericPagerField.cs
- ColumnHeader.cs
- TableRowCollection.cs
- NamedPipeAppDomainProtocolHandler.cs
- DbException.cs
- TraceSource.cs
- BuildProvidersCompiler.cs
- InputProcessorProfilesLoader.cs
- CompositeDataBoundControl.cs
- RuleSetBrowserDialog.cs
- ReflectionServiceProvider.cs
- SqlTypeSystemProvider.cs
- EventLogEntryCollection.cs
- EventArgs.cs
- SoapObjectWriter.cs
- SoundPlayer.cs
- DataGridRowClipboardEventArgs.cs
- _BufferOffsetSize.cs
- dataobject.cs
- XamlToRtfParser.cs
- BuildProvider.cs
- ScriptRegistrationManager.cs
- URLIdentityPermission.cs
- CompositeActivityDesigner.cs
- ExpressionEvaluator.cs
- Listen.cs
- QilList.cs
- CompiledXpathExpr.cs
- TCPListener.cs
- DataSourceGroupCollection.cs
- ExpressionEditorAttribute.cs
- PenContext.cs
- EventProviderWriter.cs
- QuotedPrintableStream.cs
- PropertyTabAttribute.cs
- Floater.cs
- LockCookie.cs
- XamlSerializer.cs
- DictionaryEntry.cs
- FormClosingEvent.cs
- Form.cs
- SemanticTag.cs