コード例 #1
0
ファイル: EntityToolsGeneric.cs プロジェクト: cash2one/Z
        /// <summary>
        /// 从IDataRecord中解析对象属性
        /// </summary>
        /// <param name="target"></param>
        /// <param name="DbDataParameterList">IDbDataParameter列表</param>
        /// <returns></returns>
        public static int ToIDbParameterList(T target, IList DbDataParameterList)
        {
            int totalCount = 0;

            if (target is DataRow)
            {
                EntityTools.DataRow2DbParameterList(target as DataRow, DbDataParameterList);
                return(totalCount);
            }


            foreach (IDbDataParameter p in DbDataParameterList)
            {
                if (p.Direction != ParameterDirection.Input)
                {
                    continue;
                }

                string pName = EntityToolsInternal.GetParameterName(p);

                object o = GetValue(target, pName, false);

                if (o == null)
                {
                    p.Value = DBNull.Value;
                }
                else
                {
                    p.Value = o;
                }
            }

            return(totalCount);
        }
コード例 #2
0
ファイル: EntityToolsGeneric.cs プロジェクト: cash2one/Z
        /// <summary>
        /// 静态构造函数
        /// </summary>
        static EntityTools()
        {
            EntityToolsInternal.CalculateFieldPropertys <T>(ref FieldCount, ref PropertyCount, ref Fields, ref Propertys, ref FeildOrPropertys);

            FieldOrPropertyCount = PropertyCount + FieldCount;

            Table = EntityTools.ToDataTable(typeof(T));
            //GetValue = EntityToolsInternal.Func_GetValue<T, object>();
            GetValue_NEW   = EntityToolsInternal.Func_GetValue2 <T, object>();
            SetValue       = EntityToolsInternal.Func_SetValue <T, object>();
            GetValueString = EntityToolsInternal.Func_GetValue <T, string>();
            SetValueString = EntityToolsInternal.Func_SetValue <T, string>();
        }
コード例 #3
0
 /// <summary>
 /// 设置值
 /// </summary>
 /// <typeparam name="T">实体类型</typeparam>
 /// <param name="entity">实体对象</param>
 /// <param name="name">属性名称</param>
 /// <param name="IgnoreCase">是否忽略大小写</param>
 /// <param name="obj">属性值</param>
 public static void SetEntityValue <T>(this IEntity <T> entity, string name, bool IgnoreCase, object obj)
 {
     EntityTools <T> .SetValue((T)entity, name, IgnoreCase, obj);
 }
コード例 #4
0
 /// <summary>
 /// 取值
 /// </summary>
 /// <typeparam name="T">实体类型</typeparam>
 /// <param name="entity">实体对象</param>
 /// <param name="name">属性名称</param>
 /// <param name="IgnoreCase">是否忽略大小写</param>
 /// <returns></returns>
 public static object GetEntityValue <T>(this IEntity <T> entity, string name, bool IgnoreCase)
 {
     return(EntityTools <T> .GetValue((T)entity, name, IgnoreCase));
 }