public static string GetJoiner <E, D>() { Type firstType = typeof(E); string secondName; Type secondType = typeof(D); secondName = secondType.Name; BasicList <PropertyInfo> thisList = firstType.GetPublicPropertiesWithAttribute <ForeignKeyAttribute>().ToBasicList(); BasicList <PropertyInfo> newList = thisList.Where(items => { ForeignKeyAttribute thisKey = items.GetCustomAttribute <ForeignKeyAttribute>() !; if (thisKey.ClassName == secondName) { return(true); } return(false); }).ToBasicList(); if (newList.Count == 0) { throw new CustomBasicException($"No Key Found Linking {secondName}"); } if (newList.Count > 1) { throw new CustomBasicException($"Duplicate Key Found Linking {secondName}"); } PropertyInfo thisProp = newList.Single(); ColumnAttribute thisCol = thisProp.GetCustomAttribute <ColumnAttribute>() !; if (thisCol == null) { return(thisProp.Name); } return(thisCol.ColumnName); }