The OData query parsing library which was spun out of the MicroLite WebApi extension has undergone quite a few changes and some of those have been incorporated into the MicroLite WebApi extension.
The main difference is that the OData query support has been split out into a separate library so if you want to use WebApi controllers but don’t use OData, you no longer have a dependency on the Net.Http.WebApi.OData library. Starting with version 6.6.0 of the MicroLite WebApi extension, there are now 2 packages available:
- MicroLite.Extensions.WebApi – this contains the base WebApi integration (MicroLiteApiController etc)
- MicroLite.Extensions.WebApi.OData – this contains the MicroLiteODataApiController and supports OData 4.0 (via Net.Http.WebApi.OData 4.0.0)
What do I need to do?
“I use the WebApi extension and want OData 4.0!”
PM> Install-Package MicroLite.Extensions.WebApi.OData -Version 6.6.0
“I use the WebApi extension and don’t use OData query support”
PM> Install-Package MicroLite.Extensions.WebApi -Version 6.6.0
PM> Uninstall-Package Net.Http.WebApi.OData
Query Option Changes
$inlinecount=allpages
has been replaced by $count=true
.
The JSON response for paged results ($count=true
) has changed as follows:
data.__count
is nowdata['@odata.count']
data.results
is nowdata.value
Function Changes
The substringof
function has been replaced by contains
in the $filter
query option so substringof('Alfreds', CompanyName)
would become contains(CompanyName, 'Alfreds')
Data Type Changes:
The DateTime
type has been removed, there is a new Date
type for dates only which is a literal and doesn’t need a type prefix or quotes $filter=DateOfBirth eq 1974-08-19
. To specify date and time, use DateTimeOffset
literal instead which also no longer requires a type prefix or quotes $filter=Created gt 2002-10-15T17:34:23Z
don’t forget the timezone!.
The Guid
type no longer requires a prefix or quotes TransactionId eq guid'0D01B09B-38CD-4C53-AA04-181371087A00'
becomes TransactionId eq 0D01B09B-38CD-4C53-AA04-181371087A00
The library now requires the entity model to be defined, see the Wiki for further details.