question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] SqlExpressions, how to pass many parameters and if possible to pass linq properties

See original GitHub issue

Describe your issue

Is possible to pass many parameters in a SqlExpression?

        [Sql.Extension("ROW_NUMBER() OVER(PARTITION BY {args, ', '} ORDER BY {0}", ServerSideOnly = true)]
        public static int GetRowNumber(string orderBy, [ExprParameter] params object[] args)
        {
            throw new NotSupportedException();
        }

I’m trying to accomplish a way to make reusable a sql expression to retrieve a row number based on some columns and pass a column as ordering criteria, any idea about how to accomplish this? Final generated query should be something like:

           ROW_NUMBER() OVER(PARTITION BY foo1.name, foo1.age, foo1.birthdate
            ORDER BY foo1.age)

Environment details

Linq To DB version: Last stable version

Database (with version): Oracle

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gpgpublickeycommented, Apr 19, 2023

That worked! you are like Rihanna, you shine bright like a diamond lol thanks! ❤️ @sdanyliv

0reactions
sdanylivcommented, Apr 19, 2023

Can you try this one?

var query =
    from foo1 in _db.someTable
    select new
    {
        RowNo = Sql.Ext.RowNumber().Over()
            .PartitionBy(foo1.age, foo1.name, foo1.age)
            .OrderBy(foo1.birthdate)
            .ToValue()
    };
Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple search parameters with LINQ
I'm trying to figure out the most efficient way to search for multiple (arbitrary number of) search parameters with it. In the windows...
Read more >
How to reference an Objects property name as a parameter ...
This way I can run the method for each property I want to search for by passing in a string that replaces PropertyAsParameter...
Read more >
Lambda expressions and anonymous functions
Run(Action) method to pass the code that should be executed in the background. You can also use lambda expressions when you write LINQ...
Read more >
LINQ to SQL (Part 8 - Executing Custom SQL Expressions)
You can do this either by passing a type-object as a parameter to the method, or by using a generic-based version of the...
Read more >
7 tricks to simplify your programs with LINQ - Igor Ostrovsky
1. Initialize an array · 2. Iterate over multiple arrays in a single loop · 3. Generate a random sequence · 4. Generate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found