Commit 53a38787 authored by David O'Meara's avatar David O'Meara

An AmbiguousMatchException is encountered when the Type.GetProperty(String,...

An AmbiguousMatchException is encountered when the Type.GetProperty(String, BindingFlags) method is used and there are multiple indexers on the type, so it was replaced with a call to Type.
GetProperty(String, BindingFlags, Binder, Type, Type[], ParameterModifier[]).
parent 88766056
......@@ -4093,7 +4093,13 @@ internal static MethodInfo GetPropertySetter(PropertyInfo propertyInfo, Type typ
{
return propertyInfo.DeclaringType == type ?
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)
......
......@@ -2288,6 +2288,26 @@ select @A
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()
{
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