Open gpproton opened 1 year ago
According to the error message, you can try adding [FromQuery]
attribute but I don't think it'll work.
How do you send the request? Can you share?
The parameter should contain dot like ?CreatedAt.Min=01.01.2023
. But dot is used to initialize complex types and bind properties of that types.
Since Range<T>
is a complex type and it seems like the minimal API model binder doesn't support it.
I have a sample Filter below which i'm trying to use a date range filter with in asp.net core 7, i'm not that this might be limitation of asp.net minimal API, if there's a solution any suggestion will be appreciated.
Filter sample
public class ClaimFilter : GenericFilter { [CompareTo("Description", "Notes", CombineWith = CombineType.And)] [StringFilterOptions(StringFilterOption.Contains)] public string? Search { get; set; } public ClaimStatus[]? Status { get; set; } public Range<DateTime> CreatedAt { get; set; } // Current work around // [CompareTo("CreatedAt")] // [OperatorComparison(OperatorType.GreaterThanOrEqual)] // public DateTime? StartDate { get; set; } // // [CompareTo("CreatedAt")] // [OperatorComparison(OperatorType.LessThanOrEqual)] // public DateTime? EndDate { get; set; } }
Your current workaround seems good at the moment. Sending those parameters separated works well.
I have a sample Filter below which i'm trying to use a date range filter with in asp.net core 7, i'm not that this might be limitation of asp.net minimal API, if there's a solution any suggestion will be appreciated.
Filter sample
Minimal API sample
Error message