//获取当前项目下所有实体的命名空间 var nameSpaceAll = Assembly.GetExecutingAssembly().GetTypes(); //找到想要的那个 //var fullName = nameSpaceAll.Where(x => x.Name == tableName.ToString()).FirstOrDefault().FullName; Type t = nameSpaceAll.Where(x => x.Name == tableName.ToString()).FirstOrDefault(); Type type = null; if (t != null) { type = Type.GetType(t.FullName, true, true); }