I have a model with several classes with inheritance. I have a 4-level hierarchy:
--First level abstrac class A
--Second level abstrac class AA
*abstract class AAA
*abstract class AAB
*abstract class AAC
*abstract class AAF
*abstract class AAI
This is just one of the hierarchies. There be at least 3 more, which are less complex. They have several relationships between them, and almost all classes have more than 7 properties.
Now, I am using Table per Type but when I do a simple LINQ query like:
using (Logic.Context dc = new Logic.Context())
var prod = dc.AA.FirstOrDefault();
AA contains all the subclasses. When database is empty, it takes around 25 secs to do this simple test . It takes just 2 secs to do the same LINQ query with a fourth-level class.
I have tried to migrate to Table per Hierarchy, the database is generated well by default with a column Discriminator but the same test takes forever... The LINQ query is never executed, and it doesn't even completed. And this happens with all tables.
>>The LINQ query is never executed, and it doesn't even completed. And this happens with all tables.
Please have a try to use codes like below to check whether the query has been excuted:
using (FourLevelContext db = new FourLevelContext())
AAAA resultA = db.AA.OfType<AAAA>().FirstOrDefault<AAAA>();
AAAB resultB = db.AA.OfType<AAAB>().FirstOrDefault<AAAB>();
In my test, the query actually has been executed and the result has be returned:
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
HERE to participate the survey.