type.GetProperty("").GetValue(models[i], null);
标签类
public class Tag : ModelBase { public Tag() { SortID = 99; } /// <summary> /// 产品标签名 /// </summary> [Required(ErrorMessage = "标签名不能为空")] public string Title { get; set; } /// <summary> /// 该标签是否显示 /// </summary> public bool IsShow { get; set; } /// <summary> /// 排序,初始99 /// </summary> public int SortID { get; set; } public virtual ICollection<ProductTag> ProductTags { get; set; } }
var model=new Tag();
Type type = models[i].GetType();
type.GetProperty("Title").GetValue(model, null);
根据属性名获取相应的值
时间: 2024-10-10 05:23:20