示例#1
0
        private static OrmDbType DbType(Type t, List <Type> tableTypes, HashSet <Constraint> constraints, ITypeMapper typeMapper)
        {
            var ddlType   = typeMapper.GetDbType(t);
            var pstmtType = PreparedStatementTypeMapper.Map(t);

            if (tableTypes.Any(tType => tType == t))
            {
                ddlType   = typeMapper.GetForeignKeyType();
                pstmtType = PreparedStatementTypeMapper.GetForeignKeyType();
            }
            if (constraints.Any(c => c.GetType() == typeof(Pk)))
            {
                ddlType = typeMapper.GetPrimaryKeyType();
            }
            // because we always want to enforce enums to be text
            if (t.IsEnum)
            {
                ddlType = typeMapper.GetEnumType();
            }

            return(new OrmDbType(
                       ddlType,
                       pstmtType
                       ));
        }