Last active
December 14, 2016 02:20
-
-
Save foyzulkarim/de69373ab5e49d44189f992112c1f71c to your computer and use it in GitHub Desktop.
Check whether a specific property is actually a Foreign Key of that model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static bool IsForeignKey(PropertyInfo property, List<PropertyInfo> allProperties) | |
{ | |
return allProperties.Where(x => x.CustomAttributes.Any(y => y.AttributeType.Name == "ForeignKeyAttribute")).ToList() | |
.Any(x => | |
x.CustomAttributes.Where(y => y.AttributeType.Name == "ForeignKeyAttribute") | |
.Any(z => z.ConstructorArguments.Any(a => a.Value.ToString() == property.Name))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment