c# - Using reflection to select some properties -
how select properties of class. let's have class
public class baseentity { protected string _createdby; protected datetime _createddate; protected string _updatedby; protected datetime _updateddate; //set } public class user : baseentity { private string _username; private string _password; private employee _employee; //set }
i want select username, password, , employee, not createdby, createddate, updatedby, , updateddate. there way this? i've tried searching google, found nothing can hardcode it, this
if (!propertyinfo.name.equals("createddate") || !propertyinfo.name.equals("createdby")) { }
you should use bindingflags.declaredonly flag in type.getproperties() call, ignore inherited properties.
Comments
Post a Comment