Support objects for raw sql parameters & array parameters

Open
#24,888 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, sql
Domain
backend, databases

Research direction

No files, tests, or entry points are named in the issue. Begin by locating EF Core's raw SQL parameter entry points and comparing their current behavior with the requested Dapper-style object and array parameters. Done means supporting named object properties and array parameters for IN clauses.

Written by the indexing model from the issue text.

Description

area-query needs-design

Since EF core's goal is to reduce the amount of scenarios to resort to including Dapper for supporting raw sql support, I would suggest EF core implementing these features from Dapper:

  • dapper allows to specify named arguments in SQL queries as objects (both typed or anonymous). The names of the properties of the object are used to declare SQL variable (e.g. declare @id int = 14) so you can use these names inside the raw sql to reference the passed sql parameters)
  • dapper also allows the properties of a parameter object to be an array type, so they can be used in 'in clause' (dapper implements this apparently by defining multiple declare vars one for each element in the array and automatically inserts these vars inside an 'in clause').
  • named vars greatly improves the readability of the raw sql ( one can use names instead of string interpolation with numbers {0}, {1} ...
  • the advantage also is that generate sql can be copy and pasted in SQL running without modifications
Dominant language
C#
Stars
14.8k
Forks
3.4k
Avg merge
2d 5h
Merged PRs (30d)
134

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/efcore

All issues in dotnet/efcore

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.