Commit 36fdd579 authored by Marc Gravell's avatar Marc Gravell

Merge pull request #126 from davidomeara/master

AmbiguousMatchException with multiple indexers
parents a8043e02 53a38787
...@@ -4241,7 +4241,13 @@ internal static MethodInfo GetPropertySetter(PropertyInfo propertyInfo, Type typ ...@@ -4241,7 +4241,13 @@ internal static MethodInfo GetPropertySetter(PropertyInfo propertyInfo, Type typ
{ {
return propertyInfo.DeclaringType == type ? return propertyInfo.DeclaringType == type ?
propertyInfo.GetSetMethod(true) : propertyInfo.GetSetMethod(true) :
propertyInfo.DeclaringType.GetProperty(propertyInfo.Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetSetMethod(true); propertyInfo.DeclaringType.GetProperty(
propertyInfo.Name,
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
Type.DefaultBinder,
propertyInfo.PropertyType,
propertyInfo.GetIndexParameters().Select(p => p.ParameterType).ToArray(),
null).GetSetMethod(true);
} }
internal static List<PropertyInfo> GetSettableProps(Type t) internal static List<PropertyInfo> GetSettableProps(Type t)
......
...@@ -2290,6 +2290,26 @@ select @A ...@@ -2290,6 +2290,26 @@ select @A
var item = connection.Query<int>("#TestProcWithIndexer", new ParameterWithIndexer(), commandType: CommandType.StoredProcedure).Single(); var item = connection.Query<int>("#TestProcWithIndexer", new ParameterWithIndexer(), commandType: CommandType.StoredProcedure).Single();
} }
public class MultipleParametersWithIndexerDeclaringType
{
public object this[object field] { get { return null; } set { } }
public object this[object field, int index] { get { return null; } set { } }
public int B { get; set; }
}
public class MultipleParametersWithIndexer : MultipleParametersWithIndexerDeclaringType
{
public int A { get; set; }
}
public void TestMultipleParametersWithIndexer()
{
var order = connection.Query<MultipleParametersWithIndexer>("select 1 A,2 B").First();
order.A.IsEqualTo(1);
order.B.IsEqualTo(2);
}
public void Issue_40_AutomaticBoolConversion() public void Issue_40_AutomaticBoolConversion()
{ {
var user = connection.Query<Issue40_User>("select UserId=1,Email='abc',Password='changeme',Active=cast(1 as tinyint)").Single(); var user = connection.Query<Issue40_User>("select UserId=1,Email='abc',Password='changeme',Active=cast(1 as tinyint)").Single();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment