Note that there are some explanatory texts on larger screens.

plurals
  1. POEF Table-per-type perfomance
    text
    copied!<p>In Table-Per-Type inheritance schema Entity Framework uses "CASE WHEN .. THEN" When I have significant number of types, sql queries become extremely large and complex. So, when I have more than 30 types (simple, with one key and one text field) in hierarchy can grow up to hundreds of kilobytes, and most part of it is "CASE WHEN ..."</p> <p>So, my question is there any way to instruct EF to don't load all fields for all inherited types. For example, if I have </p> <pre><code>public class A { [Key] public int Id {get;set;} } public class B : A { public virtual string FieldB {get;set;} } public class C : A { public virtual string FieldC {get;set;} } </code></pre> <p>when I execute query </p> <pre><code>context.Set&lt;A&gt;().ToArray() </code></pre> <p>it gets not only A.Id, but also B.FieldB and C.FieldC</p> <p>this could be very important if I use context.Set().Single(a=>a.Id == itemId) with many inheritors of A query becomes enormous;</p> <p>Is there any way to use DynamicProxy, to get only A.Id, and get other fields in lazy way by proxies?</p> <hr> <p>Update:</p> <p>Real-world example of deep-inherited entities that we use is documents:</p> <p>For example there are base class IncomingDocument, with Id, Date, Number.</p> <p>Then, depends of department, it could be BankingIncomingDocument (with AccountNumber, for example) , DepositaryIncomingDocument (with FinancialTool), etc. (up to 5-6 departments).</p> <p>Then, for each department could be specific document, TransferFundsBankIncomingDocument, CloseAccoundBankIncomingDocument, etc.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload