Architecture, EF Core 8 and large SQL queries best practice question

32 views Asked by At

I have a couple of large SQL scripts, but one particular in general which I would like to use as a stored procedure (but I dont since I am not the biggest fan of stored procedures for this kind of query).

My question isnt about the actuall script, but how I should in "best practice" handle a big SQL query which I need to run as RawSql with EF Core. The script takes some parameters and so on.

Should I:

  • Store the script in a .sql file in the project and use some kind of Regex.Replace for the parameters in the actual content of the file?
  • Should I just have a class with SQL scripts which takes in parameters and uses the $"select * from x where column = '{myParameter}'"?

Thanks in advance!

Best regards Max

0

There are 0 answers