try this by using LINQ-TO-OBJECT to find out all the properties, and then use GetCustomAttributes to find out which fits well.
通过GetProperties()方法获取列名list,即linq to sql 语句获取;
namespace nibian { /// <summary> /// Suppose this is a class that has two "Required" attributes /// </summary> public class Model { [Required] public int Id { get; set; } [Required] public string Name { get; set; } public double Score { get; set; } } public class MainTest { static void Main(string[] args) { // This will search for each Attributes applied onto the property // to find out whether "Required" exists or not. var properties = typeof(Model).GetProperties().Where(p => p.GetCustomAttributes(typeof(RequiredAttribute), false).Length==1).Select(p=>p); // This will output the Name of the assigned public properties. foreach (var item in properties) { Console.WriteLine(item.Name); } } } }