如何只选择类的一些属性。假设我有课
public class BaseEntity
{
protected string _createdBy;
protected DateTime _createdDate;
protected string _updatedBy;
protected DateTime _updatedDate;
//set get
}
public class User : BaseEntity
{
private string _username;
private string _password;
private Employee _employee;
//set get
}
我只想选择Username,Password和Employee,而不是CreatedBy,CreatedDate,UpdatedBy和UpdatedDate。有没有办法做到这一点?我试过谷歌搜索,但我一无所获 所以我只能硬编码,就像这样
if (!propertyInfo.Name.Equals("CreatedDate") ||
!propertyInfo.Name.Equals("CreatedBy"))
{
}