using System; using System.Collections.Generic; using System.Linq; using System.Reflection; namespace ChangkeTec.SDMS.Model { public class EntityClassInfo { public EntityClassInfo() { var classNameList = new List(); var properties = typeof(T).GetProperties(); // 获得对象所有属性 foreach (var property in properties) { var propertyType = property.PropertyType.Name; // 获得属性类型名称 if (!propertyType.Contains("DbSet")) continue; var genericTypes = property.PropertyType.GenericTypeArguments; // 获得泛型类型数组 classNameList.AddRange(genericTypes.Select(type => type.Name)); } this.EntityNameList = classNameList; } public List EntityNameList { get; set; } } }