Closed tspence closed 2 years ago
Apparently this only fails on nullable datetime types, not regular datetime types.
Okay, this is odd. I haven't been able to repro it in my test suite. The error being thrown is System.InvalidOperationException: No generic method 'OrderBy' on type 'System.Linq.Queryable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.
- it seems there is some subtle difference between the test suite that is failing and the Searchlight test suite that is passing.
Found the root cause. Our unit test was sorting on a column, InvoiceDate
, which is stored as a string in the API model but is stored as a DateTime?
in the database. The root cause of this is the difference between the model data type and the database data type - it was failing to match the correct types.
Solution is to add this annotation to the model:
[SearchlightField(FieldType = typeof(DateTime?))]
This tells Searchlight to correctly query the field by its raw type.
Possible solutions:
Addressed by #106
Version 0.9.19 generates an exception when ordering by a DateTime value