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;