/// <summary> /// 映射数据库中的类型、枚举、表 /// </summary> /// <param name="assembly">包含类型的程序集</param> /// <param name="perfix">前辍过滤</param> /// <param name="connection">连接实例</param> public static void MapTypes(System.Reflection.Assembly assembly, string perfix = null, object connection = null) { MapTypeHelper helper = new MapTypeHelper(connection); MapTypes_Filter filter = null; if (string.IsNullOrEmpty(perfix)) { filter = (p1) => true; } else { filter = (p1) => p1.Name.StartsWith(perfix, System.StringComparison.OrdinalIgnoreCase); } foreach (System.Type type in assembly.GetTypes()) { #if NETDNX if (type.GetTypeInfo().IsAbstract || !filter(type)) #else if (type.IsAbstract || !filter(type)) #endif { continue; } helper.MapType(type); } }
/// <summary> /// 映射数据库中的类型、枚举、表 /// </summary> /// <param name="type">类型</param> /// <param name="connection">连接实例</param> /// <returns>返回是否成功</returns> public static bool MapType(System.Type type, object connection = null) { #if NETDNX if (type == null || type.GetTypeInfo().IsAbstract) #else if (type == null || type.IsAbstract) #endif { return(false); } MapTypeHelper helper = new MapTypeHelper(connection); return(helper.MapType(type)); }