DapperLib / DapperLib/Dapper

How to pass IEnumerable<T> (or 'rows of data') as parameter?

Open
#541 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

Hi, the purpose is to pass a list of "rows" to a Stored Procedure that will handle inserting or updating based on something internal in the DB, the SP takes a parameter "Filter" which is a "User-defined data type".
The closest I've found is this: execute-a-command-multiple-times

I'm using version 1.50.0-rc2b
(At first I was trying to use a System.Data.DataTable but it seems unsupported in aspnet core)

As in issue 540 I'm getting this Exception:

The member of type Data.Models.ProfileFilter cannot be used as a parameter value

My code:
`public void Save(Profile profile){

var profileSettings = new List<ProfileFilter>();
profileSettings.Add(new ProfileFilter() { FilterTypeId = 1, Value = "30000" });
profileSettings.Add(new ProfileFilter() { FilterTypeId = 4, Value = "Test" });
using (var conn = getConnection())
{
    var param = new
    {
        profileId = 222,
        email = "my@email.com",
        filter = profileSettings
    };
    conn.Execute("Save_ProfileUser", param, commandType: System.Data.CommandType.StoredProcedure);
}

}
`

Thanks!

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start with the Save method and its Save_ProfileUser stored procedure, then review issue 540 and the reported Data.Models.ProfileFilter parameter exception. Determine the supported path for passing profileSettings rows or a DataTable to the user-defined type, and confirm completion with a working stored-procedure call.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.