Currently I'm trying to work with Named Parameters
using SAP Sybase SQL Anywhere 12
with dapper. The following codes runs correctly:
public class Test
{
public int Str1
{
get;
set;
}
public string Str2
{
get;
set;
}
}
class Program
{
static void Main(string[] args)
{
using (SAConnection connection = new SAConnection("..."))
{
connection.Open();
Test test = connection.Query<Test>("SELECT :Str1 as Str1, :Str2 as Str2",
new Test() { Str1 = 35, Str2 = "42" }).FirstOrDefault();
Console.WriteLine($"Str1: {test.Str1} | Str2: {test.Str2}");
Console.ReadLine();
}
}
}
But when i change Str2 = "42"
to some string
, than i get the following exception:
Cast 42a to integer not possible
This exception is thrown when I'm using the following code:
Test test = connection.Query<Test>("SELECT :Str1 as Str1, :Str2 as Str2",
new Test() { Str1 = 35, Str2 = "42a" }).FirstOrDefault();
Is there some known issue? This should work correctly, cause i just want to pass a string around.
Edit
Stack trace:
iAnywhere.Data.SQLAnywhere.SAException (0x80004005): Umwandeln von '42a' auf integer nicht möglich bei iAnywhere.Data.SQLAnywhere.SACommand._ExecuteReader(CommandBehavior commandBehavior, Boolean isExecuteScalar, Boolean isBeginExecuteReader) bei iAnywhere.Data.SQLAnywhere.SACommand.ExecuteDbDataReader(CommandBehavior behavior) bei System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) bei Dapper.SqlMapper.d__61
1.MoveNext() bei System.Collections.Generic.List
1..ctor(IEnumerable1 collection) bei System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source) bei Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable1 commandTimeout, Nullable
1 commandType) bei DapperSqlAnywhere.Program.Main(String[] args) in C:\Users....\DapperSqlAnywhere\Program.cs:Zeile 35.
Thanks a lot!