Skip to content

Commit

Permalink
Fix incorrect GetProperties method logic (based on dotnet docs)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarabika authored and xuzhg committed Jul 13, 2021
1 parent 924083f commit 89bc046
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,13 @@ internal Expression CreatePropertyValueExpression(IEdmStructuredType elementType

// Expression: source.Property
string propertyName = _model.GetClrPropertyName(property);
PropertyInfo propertyInfo = source.Type.GetProperties().First(p => p.Name == propertyName);

PropertyInfo propertyInfo = source.Type.GetProperty(propertyName, BindingFlags.DeclaredOnly);
if (propertyInfo == null)
{
propertyInfo = source.Type.GetProperty(propertyName);
}

Expression propertyValue = Expression.Property(source, propertyInfo);
Type nullablePropertyType = TypeHelper.ToNullable(propertyValue.Type);
Expression nullablePropertyValue = ExpressionHelpers.ToNullable(propertyValue);
Expand Down

0 comments on commit 89bc046

Please sign in to comment.