Azavea.Open.DAO.AbstractDaLayer.GetDataType C# (CSharp) Method

GetDataType() protected method

Given the class mapping and the column name, determines the appropriate c# data type.
protected GetDataType ( string col, ClassMapping mapping ) : Type
col string Column to look up.
mapping ClassMapping Mapping for the class we're creating a table for.
return System.Type
        protected Type GetDataType(string col, ClassMapping mapping)
        {
            Type colType = null;
            // Use the explicit type if there is one.
            if (mapping.DataColTypesByDataCol.ContainsKey(col))
            {
                colType = mapping.DataColTypesByDataCol[col];
            }
            // Otherwise use the type of the member on the mapped object.
            if ((colType == null) && (mapping.AllObjMemberInfosByDataCol.ContainsKey(col)))
            {
                MemberInfo info = mapping.AllObjMemberInfosByDataCol[col];
                if (info is FieldInfo)
                {
                    colType = ((FieldInfo)info).FieldType;
                }
                else if (info is PropertyInfo)
                {
                    colType = ((PropertyInfo)info).PropertyType;
                }
            }
            // Default behavior is assume string since pretty much everything can be stored
            // as a string.  This should generally only happen for DictionaryDAOs.
            if (colType == null)
            {
                colType = typeof(string);
            }
            return colType;
        }