예제 #1
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="row">数据行</param>
        /// <param name="columns">列集合</param>
        /// <returns>数据表实体</returns>
        protected override T CreateEntity(DataRow row, DataColumnCollection columns)
        {
            T entity = new T();

            PropertyInfo[] props = this._entityType.GetProperties();

            foreach (PropertyInfo prop in props)
            {
                DatabaseColumnAtrribute attr = null;

                if (this._columns.TryGetValue(prop.Name, out attr) && attr != null)
                {
                    DbType dbType = (attr.DbType.HasValue ? attr.DbType.Value : DbTypeHelper.InternalGetDbType(prop.PropertyType));
                    Object value;

                    if (this.IsNullableType(prop.PropertyType))
                    {
                        value = this.LoadNullableValue(row, columns, attr.ColumnName, dbType);
                    }
                    else
                    {
                        value = this.LoadValue(row, columns, attr.ColumnName, dbType);
                    }

                    prop.SetValue(entity, value, null);
                }
            }

            return(entity);
        }
예제 #2
0
 /// <summary>
 /// 创建新的Sql语句参数类
 /// </summary>
 /// <param name="columnName">字段名</param>
 /// <param name="parameterName">参数名</param>
 /// <param name="value">赋值内容</param>
 /// <returns>Sql语句参数类</returns>
 public static SqlParameter Create(String columnName, String parameterName, Object value)
 {
     return(SqlParameter.Create(columnName, parameterName, DbTypeHelper.InternalGetDbType(value), value));
 }
예제 #3
0
 /// <summary>
 /// 创建新的Sql语句参数类
 /// </summary>
 /// <param name="columnName">字段名</param>
 /// <param name="value">赋值内容</param>
 /// <returns>Sql语句参数类</returns>
 public static SqlParameter Create(String columnName, Object value)
 {
     return(SqlParameter.Create(columnName, columnName.Replace("(", "_").Replace(")", ""), DbTypeHelper.InternalGetDbType(value), value));
 }