Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void Select_WithExpression_GeneratesCorrectUrl()
.BuildUrl();

url.Should().Contain("$select=");
url.Should().Contain("Id");
url.Should().Contain("ID");
url.Should().Contain("Name");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ private static string GetMemberPath(MemberExpression member)

while (current is MemberExpression memberExpr)
{
pathStack.Push(memberExpr.Member.Name);
var jsonPropertyNameAttribute = memberExpr.Member.GetCustomAttribute<JsonPropertyNameAttribute>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ LOW RISK

Suggestion: Calling GetCustomAttribute repeatedly during expression parsing adds reflection overhead to every query segment. Since property name mappings are static for the lifetime of the application, consider caching these results in a ConcurrentDictionary<MemberInfo, string> to improve performance in high-throughput scenarios.

Try running the following prompt in your coding agent:

In ODataQueryBuilder.ExpressionParsing.cs, introduce a static ConcurrentDictionary to cache the mapping from MemberInfo to the property name resolved from JsonPropertyNameAttribute within the GetMemberPath method.

pathStack.Push(jsonPropertyNameAttribute?.Name ?? memberExpr.Member.Name);
current = memberExpr.Expression;
}

Expand Down