Given a property in a class, with attributes – what is the fastest way to determine if it contains a given attribute? For example:
[IsNotNullable]
[IsPK]
[IsIdentity]
[SequenceNameAttribute("Id")]
public Int32 Id
{
get
{
return _Id;
}
set
{
_Id = value;
}
}
What is the fastest method to determine that for example it has the “IsIdentity” attribute?
There’s no fast way to retrieve attributes. But code ought to look like this (credit to Aaronaught):
If you need to retrieve attribute properties then