Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8636707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:17:35+00:00 2026-06-12T10:17:35+00:00

I have simple SQL string like this: SELECT * FROM Office WHERE OfficeId IN

  • 0

I have simple SQL string like this:

"SELECT * FROM Office WHERE OfficeId IN @Ids"

The thing is that the @Ids name is entered in an editor so it could be whatever, and my problem is that if I want to pass in, say an array of integers, it only works with Dapper if I use:

var values = new DynamicParameters();
values.AddDynamicParams(new { Ids = new[] { 100, 101 } });

But this requires me to KNOW that the parameter name is Ids and that’s not the case in my scenario.

I can set a “dynamic parameter” in Dapper with a “dynamic” name like this:

var values = new DynamicParameters();
values.Add("Ids", new[] { 100, 101 });

But then Dapper doesn’t construct the IN (....) SQL with separate parameters for each value.

Is there a way to construct the dynamic object passed in to AddDynamicParams but setting the member name and value without knowing the name beforehand?

I could modify the Dapper source to work for my scenario, but if anyone know of a simpler and elegant solution to this I would be greatful!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:17:36+00:00Added an answer on June 12, 2026 at 10:17 am

    I have just submitted a fix to the repository that allows any of the following to work correctly:

    by object (this worked previously):

    values.AddDynamicParams(new { ids = list });
    

    or, by single name:

    values.Add("ids", list);
    

    or, as a dictionary:

    var args = new Dictionary<string, object>();
    args.Add("ids", list);
    values.AddDynamicParams(args);
    

    I have not yet deployed to NuGet. Let me know if this is a problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this very simple sql statement: SELECT max_dose FROM psychotropes WHERE (patient_meds.psychotrope =
I have a very very simple SQL string that MS Access doesn't seem to
I have a simple function converts date to java.sql.date . public static java.sql.Date getSqlDate(String
I have a simple SQL query in PostgreSQL 8.3 that grabs a bunch of
I have a simple SQL query: Select ID, COUNT(ID) as Selections, OptionName, SUM(Units) as
I have a simple SQL query (using SqlCommand, SqlTransaction) in .NET 2.0 that returns
I have simple SSIS package where I import data from flat file into SQL
I have a table called activities that looks like this id | related_id |
I have a list like this: List tripIds = new ArrayList() def sql =
Given SQL Server 2008, I have written a simple find in string function as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.