I have a simple class like this :
public class User
{
public Guid Id{ get; set; }
public string UserName { get; set; }
public byte[] RowVersion { get; set; }
}
Rowversion column in Db tabale get auto value.when I Inser an user with dapper
var result = db.Execute("[dbo].[User_Insert]", user, trans,commandType:CommandType.StoredProcedure);
Dapper generate parameter for all property and I get error like this
Procedure or function User_Insert has too many arguments specified.
How can I ignore Rowversion in Dapper parameter?
My procedure code is:
ALTER PROCEDURE [In4].[User_Insert]
@Id uniqueidentifier,
@UserName nvarchar(4000)= NULL
AS
BEGIN
insert into [In4].[Users] ([Id], [UserName])
VALUES (@Id, @UserName)
End
You could pass in an anonymous object with only the properties you want.
var result = db.Execute("[dbo].[User_Insert]", new { user.Id, user.UserName }, trans, commandType:CommandType.StoredProcedure);
Alternatively, you could use the Dapper Contrib extensions and create a mapping class, which allows you to ignore specific properties.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With