Dapper Contrib does not support HANA?
Using Get method with HanaConnection and OdbConnection classes I get an error, it seems that the placeholder for the Id in the query (an @, I always have used ? for Hana) is not replaced.
Code:
HanaConnection connection = new HanaConnection("connectionString");
connection.Open();
var invoice = connection.Get<Invoice>(63829);
My Invoice class:
[Table("OINV")]
public class Invoice
{
[ExplicitKey]
public int DocEntry { get; set; }
public string CardCode { get; set; }
public string FakeProperty { get; set; }
}
The error:
I am not familiar with that DB. Can you show what you would have used with manual ADO-NET? It sounds like ?foo? etc should work (mapping to the value named foo in the args passed)
On Thu, 27 Aug 2020, 09:13 dvm-j, [email protected] wrote:
Using Get https://dapper-tutorial.net/get method with HanaConnection and OdbConnection classes I get an error, it seems that the placeholder for the Id in the query (an @, I always have used ? for Hana) is not replaced.
Code:
HanaConnection connection = new HanaConnection("connectionString"); connection.Open(); var invoice = connection.Get<Invoice>(63829);
My Invoice class:
[Table("OINV")]public class Invoice { [ExplicitKey] public int DocEntry { get; set; } public string CardCode { get; set; } public string FakeProperty { get; set; } }
The error:
[image: syntax-error-dapper] https://user-images.githubusercontent.com/47435846/91414962-98172180-e84d-11ea-86ec-119672738f8b.JPG
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/StackExchange/Dapper/issues/1526, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEHMDXXE44H3IFKXVYBFTSCYIRHANCNFSM4QMWNI2Q .
Sorry for the delay. Using ADO it looks like this, either with Hana or Odbc classes.
HanaConnection connection = new HanaConnection("connectionString");
connection.Open();
var command = new HanaCommand(@"SELECT ""DocEntry"", ""CardCode"" FROM OINV WHERE ""DocEntry"" = ?", connection);
command.Parameters.AddWithValue("DocEntry", 63829);
var reader = command.ExecuteReader();
while(reader.Read())
{
var invoice = new Invoice();
invoice.DocEntry = Convert.ToInt32(reader["DocEntry"]);
invoice.CardCode = reader["CardCode"].ToString();
Console.WriteLine("Invoice #{0}. Customer: {1}.", invoice.DocEntry, invoice.CardCode);
}
Using regular Dapper this also works:
string query = @"SELECT ""DocEntry"", ""CardCode"" FROM OINV WHERE ""DocEntry"" = ? ";
var invoice = connection.QueryFirstOrDefault<Invoice>(query, new { DocEntry = 63829 });
Console.WriteLine("Invoice #{0}. Customer: {1}.", invoice.DocEntry, invoice.CardCode);
Can confirm this issue. I am not using Dapper.Contrib but the original Dapper and got the same error. Seems like query params having the "@"-notation are not replaced correctly. Using "?" works.
The default parameter prefix for HANA is a colon ":" not an "@" if that's helpful.
You must pass parameter between ?
Example SELECT * FROM "table" WHERE ""col"" = ?col?