Dapper.Contrib
Dapper.Contrib copied to clipboard
Remove "RETURNING *" or "RETURNING Id" in Dapper.Contrib
Currently, it seems to me that Dapper.Contrib's InsertAsync
generates SQL with RETURNING
, is there any way we can remove this with configuration? If not, supporting it would be great.
My problem is InsertAsync
adds RETURNING Id
at the end of my query. But my column name is "Id"
with quotes. But when this query is sent to PostgreSQL, it gives this error: Column id does not exist.
Removing the last returning clause will solve my problem because I'm not using any return value in my insert query.
Also, in PostgresAdapter, AddColumnName
adds with quotes like this "Price"
, but adding returning clause adds without quotes like this: Id
.
The code that causes "Column id does not exist" error:
[Table("\"Products\"")]
public class Product
{
public long Id { get; set; }
public string Name { get; set; }
}
public async Task<int> InsertAsync(IDbConnection connection, Product product)
{
return await connection.InsertAsync(product);
}
My database schema:

@dogac00 , Postgres being a case sensitive database, Ideally I would either use Lowercase or Snake case for column names