Note that there are some explanatory texts on larger screens.

plurals
  1. POEF extend query per case
    text
    copied!<p>I have the following case:</p> <p>I need to execute the following linq query on an EF context</p> <pre><code>from table1 in context.TableOne join table2 in context.TableTwo on table1.SomeFKId equals table2.Id join table3 in context.TableThree on table2.SomeFKId equals table3.Id ... join tableN in context.TableN on tableN_1.SomeFKId equals tableN.Id where case1 &amp;&amp; case2 &amp;&amp; case3 ... &amp;&amp; caseN select new TablesDto { VarOne = table1.Var , VarTwo = tableN_2.var } </code></pre> <p>My problem is that I want to use the same query in diffirent senarios with alot of extentions. I would rather not write it many times (DRY principle) just extend it but not at the cost of efficiency and speed.</p> <p>That is if I wanted to join the first table with another I could extend the Dto to incorporate the rest of the variables but if I were to iterate through the rows I would need a query per row to extend it. Since I am talking about 100 to 5000 rows, even the iteration would take some time.</p> <p>Extentions include: Other cases (case1, case2 etc) and other joins.</p> <p>Extention Example:</p> <pre><code>from table1 in context.TableOne join table2 in context.TableTwo on table1.SomeFKId equals table2.Id join table3 in context.TableThree on table2.SomeFKId equals table3.Id ... join tableN in context.TableN on tableN_1.SomeFKId equals tableN.Id join extTable in context.TableExt on table2.SomeFKId equals extTable.Id where case1 &amp;&amp; case2 &amp;&amp; case3 ... &amp;&amp; caseN || extTable.NumOfSmth == 4 select new ExtTablesDto { VarOne = table1.Var , VarTwo = tableN_2.var , ExtVar = extTable.Name } </code></pre>
 

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