小编she*_*hbi的帖子

Lambda表达式 - 它是否正确评估?

我有以下代码似乎没有正确行事.有一个属性有一个属性不是类型FieldMapAttribute,但它仍然进入if条件,我检查匹配该类型属性的计数.

foreach (PropertyInfo _property in _properties)
{
    var attributes = _property.GetCustomAttributes(false);
    if (attributes.Select(a => a.GetType() == typeof(FieldMapAttribute)).Count() > 0)
    {
        colname = (attributes.Select(a => a.GetType() == typeof(FieldMapAttribute)).Cast<FieldMapAttribute>().First()).DbColumnName;
    }
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮我理解这里发生了什么吗?

.net c# linq custom-attributes

0
推荐指数
1
解决办法
328
查看次数

标签 统计

.net ×1

c# ×1

custom-attributes ×1

linq ×1