提交 d6f30259 编写于 作者: M Marc Gravell

Better matching of value-tuple names when wrong number of columns - should...

Better matching of value-tuple names when wrong number of columns - should return nulls for unmapped
上级 f5938d7b
......@@ -2237,9 +2237,8 @@ internal static IList<LiteralToken> GetLiteralTokens(string sql)
static List<IMemberMap> GetValueTupleMembers(Type type, string[] names)
{
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance);
int keep = Math.Min(fields.Length, names.Length);
var result = new List<IMemberMap>(keep);
for(int i = 0; i < keep; i++)
var result = new List<IMemberMap>(names.Length);
for(int i = 0; i < names.Length; i++)
{
FieldInfo field = null;
string name = "Item" + (i + 1).ToString(CultureInfo.InvariantCulture);
......@@ -2251,10 +2250,7 @@ static List<IMemberMap> GetValueTupleMembers(Type type, string[] names)
break;
}
}
if (field != null)
{
result.Add(new SimpleMemberMap(string.IsNullOrWhiteSpace(names[i]) ? name : names[i], field));
}
result.Add(field == null ? null : new SimpleMemberMap(string.IsNullOrWhiteSpace(names[i]) ? name : names[i], field));
}
return result;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册