Skip to content
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

SearchlightField EnumType doesn't do anything #136

Closed
charliettaylor opened this issue Sep 5, 2023 · 1 comment · Fixed by #137
Closed

SearchlightField EnumType doesn't do anything #136

charliettaylor opened this issue Sep 5, 2023 · 1 comment · Fixed by #137

Comments

@charliettaylor
Copy link
Collaborator

I was attempting to set up an enum to query on and it doesn't seem like setting the EnumType does any conversion.

Example

public enum CarType
{
    Sedan = 0,
    SUV = 1,
    // etc.
}

[SearchlightModel(OriginalName = "Car", DefaultSort = nameof(Type))]
public class Car
{
    [SearchlightField(FieldType = typeof(int), EnumType = typeof(CarType))]
    public CarType Type { get; set; }
}

If I attempt a filter like type eq Sedan, the filter fails with Searchlight.FieldTypeMismatch. There should be an automatic conversion from the enum name to the underlying value so that using type eq 0 and type eq Sedan are both valid filters.

@tspence
Copy link
Owner

tspence commented Sep 6, 2023

Good catch, thanks for reporting. We could use some more tests for enums anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants