So I've been using dapper for a few of my projects lately, and I was curious if there was any performance difference between the following samples:
With an object with many properties 30+ is there any benefit to explicitly stating the properties as opposed to just letting it figure it out on its own?
Option 1:
string sqlQuery = @"INSERT INTO [PTTicket]
([Id])
VALUES
(@Id)";
con.Execute(sqlQuery, ptTicket);
Option 2:
string sqlQuery = @"INSERT INTO [PTTicket]
([Id])
VALUES
(@Id)";
con.Execute(sqlQuery,
new
{
ptTicket.Id
}
I'm just curious if there's any benefit to manually providing the values, or if I can just pass the object and let Dapper have it's way.
Especially as the list starts to grow:
Option 1b
string sqlQuery = @"INSERT INTO [PTTicket]
([Id]
,[Name]
,[SMState]
,[CreatedByMember]
,[StartDate]
,[ClosedDate]
,[Remarks])
VALUES
(@Id
,@Name
,@SMState
,@CreatedByMember
,@StartDate
,@ClosedDate
,@Remarks)";
con.Execute(sqlQuery, ptTicket);
Option 2b.
string sqlQuery = @"INSERT INTO [PTTicket]
([Id]
,[Name]
,[SMState]
,[CreatedByMember]
,[StartDate]
,[ClosedDate]
,[Remarks])
VALUES
(@Id
,@Name
,@SMState
,@CreatedByMember
,@StartDate
,@ClosedDate
,@Remarks)";
con.Execute(sqlQuery,
new
{
ptTicket.Id,
ptTicket.Name,
ptTicket.SMState,
ptTicket.CreatedByMember,
ptTicket.StartDate,
ptTicket.ClosedDate,
ptTicket.Remarks
});