0

For a project I'm assigned to I have to alter a typeorm querybuilder to incorporate an "outer apply".

I could not find any support in typeorm for this.

I've looked for ways to do this by a join and a sub-query in the "on" of the join but the amount off data in the DB generates a timeout using multiple sub-queries. Furthermore, I looked into inserting a RAW query into the builder but could not find the mechanism for this.

Is there any way to use "apply" with typeorm?

I personally prefer to write all my queries by hand so if you come up with reasons NOT to use typeorm, I agree!! But this is an existing project and no way I'm going to rewrite it!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    I have no familiarity with TypeORM, but a quick search found this [GitHub](https://github.com/typeorm/typeorm/issues/5402) issue, which suggests it isn't supported, however, demonstrates a work around too. – Thom A Dec 22 '20 at 20:37
  • This is exactly what I tried but since the complexity of the outer apply in combination with the subquery needed to apply it got into a timeout of more than 60 seconds – Kasper Jan Mooijman Dec 22 '20 at 20:46
  • This is my personal opinion. But I feel like at a certain point, an ORM is not going to suit your needs, especially when it comes to query tuning. You may want to consider building this directly in SQL as a function/stored procedure/view (which ever fits best) in order to allow for proper query/index tuning. ORM's are great, but usually for operations that don't require tuning. – Chad Baldwin Dec 22 '20 at 23:14

0 Answers0