datarow.cs

来自「微软的行业应用解决方案示例」· CS 代码 · 共 44 行

CS
44
字号
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text;

namespace Microsoft.Mobile.Data
{
    /// <summary>
    /// Object that represents a row of columns. The columns can be retrieved 
    /// by name.
    /// </summary>
    [SuppressMessage("Microsoft.Naming",
                     "CA1710:IdentifiersShouldHaveCorrectSuffix",
                     Justification = "More readable as DataRow")]
    public class DataRow : Dictionary<string, object>
    {
        #region Methods
        /// <summary>
        /// This method allows for safe setting of a byte array from the 
        /// database. The value could be null.
        /// </summary>
        /// <typeparam name="T">type to be converted</typeparam>
        /// <param name="newValue">new value</param>
        /// <returns>a type or null</returns>
        [SuppressMessage("Microsoft.Design",
                         "CA1004:GenericMethodsShouldProvideTypeParameter",
                         Justification = "This is deliberate as the method ensures that the object is of the generic type.")]
        public static T SetValue<T>(object newValue)
        {
            T result = default(T);

            // Check to see if value is null or not
            if ((newValue != null) && (newValue != DBNull.Value))
            {
                result = (T)newValue;
            }

            return result;
        }
        #endregion
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?