(I'm using EF6 here) Say I have an abstract class:
public abstract class MyContext<T> : DbContext
and let's put it to use:
public class MyTestContext : MyContext<MyTestContext>
{
public DbSet<Object1> Object1 { get; set; }
public DbSet<Object2> Object2 { get; set; }
}
Now, say I want to iterate over all the DbSets in MyTestContext, in my abstract class. Seems this would work (this is in a method in my abstract class):
var dbSetProperties = typeof(T).GetProperties().Where(p => p.PropertyType == typeof(DbSet<>));
Yet I get "Enumeration yielded no results".
What am I doing wrong here? Thanks!
edit Note - I don't expect to know the generic type arguments up front - I'm actually looking to determine what Types are in each of the DbSets.
Aucun commentaire:
Enregistrer un commentaire