I am trying to assign static List<PropertyInfo>all the DbSetproperties in a class Entities.
However, when the code starts, List is empty because it .Where(x => x.PropertyType == typeof(DbSet)) always returns false .
I tried a number of options .Where(...), such as typeof(DbSet<>), Equals(...), .UnderlyingSystemType, etc., but does not work.
Why .Where(...)does it always return false in my case?
My code is:
public partial class Entities : DbContext
{
public static List<PropertyInfo> info = typeof(Entities).getProperties().Where(x => x.PropertyType == typeof(DbSet)).ToList();
public virtual DbSet<NotRelevant> NotRelevant { get; set; }
}
source
share