From 2d01bfe73049a2a25a4ec9186424dad6cb0c16f4 Mon Sep 17 00:00:00 2001 From: Anatoly Zhmur Date: Tue, 18 Sep 2012 15:52:35 +0400 Subject: [PATCH] Fixed issue with incorrect generated ParamReader then it has indexing properties declared. --- Dapper/SqlMapper.cs | 2 +- Tests/Tests.cs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Dapper/SqlMapper.cs b/Dapper/SqlMapper.cs index ef880e1c..65556475 100644 --- a/Dapper/SqlMapper.cs +++ b/Dapper/SqlMapper.cs @@ -1453,7 +1453,7 @@ this IDbConnection cnn, string sql, Func props = type.GetProperties().OrderBy(p => p.Name); + IEnumerable props = type.GetProperties().Where(p => p.GetIndexParameters().Length == 0).OrderBy(p => p.Name); if (filterParams) { props = FilterParameters(props, identity.sql); diff --git a/Tests/Tests.cs b/Tests/Tests.cs index 37195fa1..3351bd96 100644 --- a/Tests/Tests.cs +++ b/Tests/Tests.cs @@ -1916,6 +1916,27 @@ Order by p.Id"; item.D.Equals(true); } + public class ParameterWithIndexer + { + public int A { get; set; } + public virtual string this[string columnName] + { + get { return null; } + set { } + } + } + + public void TestParameterWithIndexer() + { + connection.Execute(@"create proc #TestProcWithIndexer + @A int +as +begin + select @A +end"); + var item = connection.Query("#TestProcWithIndexer", new ParameterWithIndexer(), commandType: CommandType.StoredProcedure).Single(); + } + class TransactedConnection : IDbConnection { IDbConnection _conn;