Method that returns an anonymous Object

Tom Meier 260 Reputation points
2024-05-13T18:34:22.9033333+00:00

Hello Friends I just have a question about the code below that uses Dapper to get data. I was wondering why do I need the code new{Id} and how does Dapper handle that one property. Thanks !

var output=_db.LoadDataItem<PayerModel, dynamic>(sql, new {Id}, connString);
Developer technologies C#
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2024-05-13T21:03:52.05+00:00

    the sql text should have parameter name @id. instead passing a parameter collection where each parameter has, a name, value and type, dapper uses reflection on the passed anonymous object.

    see:

    https://www.learndapper.com/parameters

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.