public static PrimaryKeyAttribute GetPrimaryKeyAttribute <T>(this T value) where T : class, new() { foreach (PropertyInfo info in typeof(T).GetProperties()) { PrimaryKeyAttribute primaryKeyAttribute = info.GetPrimaryKeyAttribute(); if (primaryKeyAttribute != null) { return(primaryKeyAttribute); } } return(null); }
public static PrimaryKeyAttribute GetPrimaryKeyAttribute(this PropertyInfo value) { if (value != null) { object obj2 = value.GetCustomAttributes(typeof(PrimaryKeyAttribute), false).FirstOrDefault <object>(); if (obj2 != null) { PrimaryKeyAttribute attribute = (PrimaryKeyAttribute)obj2; attribute.PrimaryProperty = value; return(attribute); } } return(null); }