You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

28 lines
895 B

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace ChangkeTec.SDMS.Model
{
public class EntityClassInfo<T>
{
public EntityClassInfo()
{
var classNameList = new List<string>();
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<string> EntityNameList { get; set; }
}
}