Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sub queries in inserts alongside parameters #468

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

patrickratzow
Copy link

@patrickratzow patrickratzow commented Apr 27, 2021

Allow mixing parameterized insert queries & query inserts.
This is very useful when you have some of the data, but is looking to get the rest of the data directly in the database without having to execute another query in C#, due to it increasing the overall time spent as a result of the extra round trip.

Example use case

var discordId = "discord_id_value";
var steamId = "steam_id_value";
var query = new Query("Discord")
    .AsInsert(
        new[] {"Id", "UserId"},
        new object[]
        {
            discordId,
            new Query("User")
                .Select("Id")
                .Where("SteamId", steamId)
        }
    );

Which would then compile into

INSERT INTO
  [Discord] ([Id], [UserId])
VALUES
  ('discord_id_value', (SELECT [Id] FROM [User] WHERE [SteamId] = 'steam_id_value'))

@ahmad-moussawi ahmad-moussawi force-pushed the master branch 2 times, most recently from 748c2bf to bad6733 Compare June 12, 2021 03:48
@torugok
Copy link

torugok commented Jun 28, 2024

Hello! Any news?
This is a very useful feature !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants