mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-21 16:26:16 +08:00
Merge pull request #51 from azhmur/master
Fixed issue with incorrect generated ParamReader when it has indexing properties declared.
This commit is contained in:
+1
-1
@@ -1453,7 +1453,7 @@ this IDbConnection cnn, string sql, Func<TFirst, TSecond, TThird, TFourth, TRetu
|
||||
il.Emit(OpCodes.Ldarg_0); // stack is now [command]
|
||||
il.EmitCall(OpCodes.Callvirt, typeof(IDbCommand).GetProperty("Parameters").GetGetMethod(), null); // stack is now [parameters]
|
||||
|
||||
IEnumerable<PropertyInfo> props = type.GetProperties().OrderBy(p => p.Name);
|
||||
IEnumerable<PropertyInfo> props = type.GetProperties().Where(p => p.GetIndexParameters().Length == 0).OrderBy(p => p.Name);
|
||||
if (filterParams)
|
||||
{
|
||||
props = FilterParameters(props, identity.sql);
|
||||
|
||||
@@ -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<int>("#TestProcWithIndexer", new ParameterWithIndexer(), commandType: CommandType.StoredProcedure).Single();
|
||||
}
|
||||
|
||||
class TransactedConnection : IDbConnection
|
||||
{
|
||||
IDbConnection _conn;
|
||||
|
||||
Reference in New Issue
Block a user