예제 #1
0
        public virtual IDataParameter[] SetParameterValue(IDataParameter[] parms, Base.IEntity entity)
        {
            if (parms == null || parms.Length == 0)
            {
                return(parms);
            }

            Type objType = entity.GetType();

            System.Reflection.PropertyInfo[] objPropertiesArray = objType.GetProperties();

            foreach (IDataParameter sParam in parms)
            {
                string pName = sParam.ParameterName.Replace("@", "");

                foreach (PropertyInfo objProperty in objPropertiesArray)
                {
                    if (objProperty.Name.ToUpper() == pName.ToUpper())
                    {
                        sParam.Value = objProperty.GetValue(entity, null) == null ? DBNull.Value : objProperty.GetValue(entity, null);
                        break;
                    }
                }

                if (((EntityBase)entity).DynamicData.ContainsKey(pName))
                {
                    sParam.Value = ((EntityBase)entity).DynamicData[pName];
                }
            }
            return(parms);
        }
예제 #2
0
        /// <summary>
        /// 모델객체를 통해서 파라메터를 만든다.
        /// </summary>
        /// <param name="entity">IEntity인터페이스를 상속받은 Entity객체</param>
        /// <returns>IDataParameter 배열</returns>
        public virtual IDataParameter[] GetParameters(Base.IEntity entity)
        {
            Type objType = entity.GetType();

            System.Reflection.PropertyInfo[] objPropertiesArray = objType.GetProperties();

            IDataParameter[] parms = GetParameters(objPropertiesArray.Length);

            for (int i = 0; i < objPropertiesArray.Length; i++)
            {
                parms[i] = GetParameter("@" + objPropertiesArray[i].Name, Convert.DBNull);
            }

            return(parms);
        }