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

Update with inner query #547

Closed
rsr-maersk opened this issue Dec 14, 2021 · 1 comment
Closed

Update with inner query #547

rsr-maersk opened this issue Dec 14, 2021 · 1 comment

Comments

@rsr-maersk
Copy link

Hi
Any idea how to:

UPDATE Foo SET [Bar] = (SELECT FORMAT(id, '00000')) where id IN (@ids)

I.e. a query assigned to the Set of a column.. I have tried all sorts. But need the a func parameter i imagine

@ahmad-moussawi
Copy link
Contributor

Yes you can use here the UnsafeLiteral to pass raw string

var query = new Query("Foo")
    .WhereIn("id", new [] {1, 2})
    .AsUpdate(new {
        Bar = new UnsafeLiteral("SELECT FORMAT(id, '0000')", replaceQuotes: false)
    });

Check this example on playground

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

No branches or pull requests

2 participants