public static BEBase MapItem(BEBase obj, IDataReader reader)
        {
            PropertyInfo[] properties = obj.GetType().GetProperties();

            foreach (PropertyInfo property in properties)
            {
                if (ReaderContainsColumn(reader, property.Name))
                {
                    if (property.PropertyType == typeof(System.String))
                    {
                        property.SetValue(obj, reader[property.Name] == DBNull.Value ? "" : Convert.ToString(reader[property.Name]), null);
                    }
                    else if (property.PropertyType == typeof(System.Int32))
                    {
                        property.SetValue(obj, reader[property.Name] == DBNull.Value ? 0 : Convert.ToInt32(reader[property.Name]), null);
                    }
                    else if (property.PropertyType == typeof(System.Int64))
                    {
                        property.SetValue(obj, reader[property.Name] == DBNull.Value ? 0 : Convert.ToInt64(reader[property.Name]), null);
                    }
                    else if (property.PropertyType == typeof(System.Double))
                    {
                        property.SetValue(obj, reader[property.Name] == DBNull.Value ? 0 : Convert.ToDouble(reader[property.Name]), null);
                    }
                    else if (property.PropertyType == typeof(System.Decimal))
                    {
                        property.SetValue(obj, reader[property.Name] == DBNull.Value ? 0 : Convert.ToDecimal(reader[property.Name]), null);
                    }
                    else if (property.PropertyType == typeof(System.Boolean))
                    {
                        property.SetValue(obj, reader[property.Name] == DBNull.Value ? false : Convert.ToBoolean(reader[property.Name]), null);
                    }
                    else if (property.PropertyType == typeof(System.DateTime))
                    {
                        property.SetValue(obj, reader[property.Name] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(reader[property.Name]), null);
                    }
                    else if (property.PropertyType.ToString().Contains("Enum"))
                    {
                        property.SetValue(obj, reader[property.Name] == DBNull.Value ? 0 : Convert.ToInt32(reader[property.Name]), null);
                    }
                }
            }
            obj.IsNew = false;
            return(obj);
        }
示例#2
0
 public virtual BEBase Get(BEBase objEntidad)
 {
     throw new Exception("");
 }
示例#3
0
 public virtual int Edit(BEBase objEntidad)
 {
     throw new Exception("");
 }
示例#4
0
 public virtual int Delete(BEBase objEntidad)
 {
     throw new Exception("");
 }