8,497
社区成员
发帖
与我相关
我的任务
分享
uploadDataList
List<string> keyList = new List<string>();
foreach (PropertyInfo pi in propertys)
{
KeyAttribute keyAttribute = (KeyAttribute)Attribute.GetCustomAttribute(t.GetType(), typeof(KeyAttribute));
if (keyAttribute != null)
{
keyList.Add(t.GetType().Name);
}
}
var keyList = new HashSet<string>();
foreach (PropertyInfo pi in properties)
{
var keyAttribute = (KeyAttribute)Attribute.GetCustomAttribute(t.GetType(), typeof(KeyAttribute));
if (keyAttribute != null)
{
if (!keyList.Add(t.GetType().Name))
{
throw new InvalidOperationException($"Key '{t.GetType().Name}'重复");
}
}
}