Exemplo n.º 1
0
 public object FromDB(ColumnMap map, object dbValue)
 {
     if (dbValue == null || dbValue == DBNull.Value)
         return null;
     else
         return Enum.Parse(map.FieldType, (string)dbValue);
 }
Exemplo n.º 2
0
        public object FromDB(ColumnMap map, object dbValue)
        {
            if (dbValue == DBNull.Value)
            {
                return DBNull.Value;
            }

            int val = (int)dbValue;

            if (val == 1)
            {
                return true;
            }
            else if (val == 0)
            {
                return false;
            }
            else
            {
                throw new ConversionException(
                    string.Format(
                    "The BooleanCharConverter could not convert the value '{0}' to a boolean.",
                    dbValue));
            }
        }
Exemplo n.º 3
0
 public object FromDB(ColumnMap map, object dbValue)
 {
     if (dbValue == null || dbValue == DBNull.Value)
         return null;
     else
         return Enum.ToObject(map.FieldType, (int)dbValue);
 }
Exemplo n.º 4
0
        public object FromDB(ColumnMap map, object dbValue)
        {
            if (dbValue == DBNull.Value)
            {
                return DBNull.Value;
            }

            string val = dbValue.ToString();

            if (val == "Y")
            {
                return true;
            }
            else if (val == "N")
            {
                return false;
            }
            else
            {
                throw new ConversionException(
                    string.Format(
                    "The BooleanYNConverter could not convert the value '{0}' to a boolean.",
                    dbValue));
            }
        }
Exemplo n.º 5
0
        public object FromDB(ColumnMap map, object dbValue)
        {
            if (dbValue == DBNull.Value)
            {
                return DBNull.Value;
            }

            if (dbValue is Double)
            {
                return dbValue;
            }

            return Convert.ToDouble(dbValue);
        }
Exemplo n.º 6
0
        public object FromDB(ColumnMap map, object dbValue)
        {
            if (dbValue == DBNull.Value)
            {
                return DBNull.Value;
            }

            if (dbValue is int)
            {
                return dbValue;
            }

            return Convert.ToInt32(dbValue);
        }
Exemplo n.º 7
0
        public object FromDB(ColumnMap map, object dbValue)
        {
            if (dbValue == DBNull.Value)
            {
                return DBNull.Value;
            }

            if (dbValue is TimeSpan)
            {
                return dbValue;
            }

            return TimeSpan.Parse(dbValue.ToString(), CultureInfo.InvariantCulture);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Tries to add a ColumnMap for the given field name.
        /// Throws and exception if field cannot be found.
        /// </summary>
        private void TryAddColumnMapForField(string fieldName)
        {
            // Set strategy to filter for public or private fields
            ConventionMapStrategy strategy = new ConventionMapStrategy(false);

            // Find the field that matches the given field name
            strategy.ColumnPredicate = mi => mi.Name == fieldName;
            ColumnMap columnMap = strategy.MapColumns(typeof(TEntity)).FirstOrDefault();

            if (columnMap == null)
            {
                throw new DataMappingException(string.Format("Could not find the field '{0}' in '{1}'.",
                                                             fieldName,
                                                             typeof(TEntity).Name));
            }
            MappedColumns.Add(columnMap);
        }
Exemplo n.º 9
0
 public object FromDB(ColumnMap map, object dbValue)
 {
     return FromDB(new ConverterContext { ColumnMap = map, DbValue = dbValue });
 }
Exemplo n.º 10
0
 public ColumnMapInfo(ColumnMap column, bool isAlt, Type type)
 {
     Map = column;
     IsAlt = isAlt;
     Type = type;
 }