-
-
Notifications
You must be signed in to change notification settings - Fork 364
feat(Sort): Sort extension method support IDynamicObject #4726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's Guide by SourceryThis PR extends the Sort functionality to support IDynamicObject by implementing a new sorting mechanism that handles dynamic objects through reflection and type casting. The implementation includes special handling for interface types and adds comprehensive unit tests using DataTable as a test case. Sequence diagram for sorting IDynamicObjectsequenceDiagram
participant Client
participant LambdaExtensions
participant DataTableDynamicContext
participant IDynamicObject
Client->>DataTableDynamicContext: Create context with DataTable
DataTableDynamicContext->>IDynamicObject: GetItems()
IDynamicObject-->>Client: Return list of dynamic objects
Client->>LambdaExtensions: Call Sort with propertyName and SortOrder
LambdaExtensions->>IDynamicObject: Check if type is IDynamicObject
alt is IDynamicObject
LambdaExtensions->>LambdaExtensions: CastAndOrder
LambdaExtensions->>IDynamicObject: Invoke sorting
IDynamicObject-->>LambdaExtensions: Return sorted items
else
LambdaExtensions->>LambdaExtensions: EnumerableOrderBySimple
end
LambdaExtensions-->>Client: Return sorted list
Class diagram for updated LambdaExtensionsclassDiagram
class LambdaExtensions {
+IEnumerable~TItem~ EnumerableOrderBy~TItem~(IEnumerable~TItem~ query, string propertyName, SortOrder sortOrder)
+IEnumerable~TItem~ EnumerableOrderBySimple~TItem~()
+IEnumerable~TItem~ EnumerableOrderByComplex~TItem~()
+IEnumerable~TItem~? CastAndOrder~TItem~(IEnumerable~TItem~ query, Type propertyType, string propertyName, SortOrder sortOrder)
+IOrderedQueryable~TItem~ OrderByInternal~TItem, TKey~(IQueryable~TItem~ query, PropertyInfo memberProperty)
+IOrderedQueryable~TItem~ OrderByDescendingInternal~TItem, TKey~(IQueryable~TItem~ query, PropertyInfo memberProperty)
+IOrderedQueryable~TItem~ ThenByInternal~TItem, TKey~(IOrderedQueryable~TItem~ query, PropertyInfo memberProperty)
+IOrderedQueryable~TItem~ ThenByDescendingInternal~TItem, TKey~(IOrderedQueryable~TItem~ query, PropertyInfo memberProperty)
+Expression~Func~TItem, TKey~~ GetPropertyLambda~TItem, TKey~(PropertyInfo pi)
}
note for LambdaExtensions "Added CastAndOrder method for dynamic object sorting"
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ArgoZhang - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4726 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 620 620
Lines 27368 27395 +27
Branches 3919 3923 +4
=========================================
+ Hits 27368 27395 +27 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Sort extension method support IDynamicObject
Summary of the changes (Less than 80 chars)
简单描述你更改了什么, 不超过80个字符;如果有关联 Issue 请在下方填写相关编号
Description
fixes #4647
Regression?
[If yes, specify the version the behavior has regressed from]
[是否影响老版本]
Risk
[Justify the selection above]
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add support for sorting IDynamicObject instances with a new Sort extension method and introduce corresponding unit tests to ensure functionality.
New Features:
Tests: