I'm creating a class that gonna work with Azure Search service. I want it to accept LINQ expressions for searching documents so outer modules dont know the Azure Search syntax.
Is there a library that can implement it? As the Azure Search is quite young, i was unable to find such one on the Internet. All i've found is RedDog package that is pretty good but still needs field names and comparison operations as strings that some day will definitely become "magic".
Okay, Azure Search also accepts OData formatted queries. I've seen few OData-query-to-LINQ-expression solutions but none that does the contrary. I need a library that can translate LINQ to OData string.
Any help is appreciated.
For OData services, you can choose to use .NET client for OData or code generator for OData which have great support of LINQ. You can refer here to know detail about how to use OData Client Generator to generate client-side proxy class and then use LIQN easily to do all queries you need. And OData Client Generator is built on top of OData Client for .NET, and I recommend that you can just start with code generator.
But please be noted that these two libraries are both for OData V4 only. If you use older OData versions, you cannot use code generator but use "Add Service Reference". And then you can also easily using LINQ for your queries.
Hope this can help you out.
You can try my GitHub project here:
https://github.com/ubergeoff/HollowPoint.Azure
Example:
HollowPoint.Azure.DbTable<People> tt = new HollowPoint.Azure.DbTable<People>();
var filter = tt.Query()
.Where(t => t.Age >= 16 && t.Age < 33)
.ToODataString();
Will output OData format string of:
((Age ge 16) and (Age lt 33))
I have just released a toolkit for Azure Search which also includes a LINQ provider. The package is named AzureSearchToolkit and is available as a NuGet https://www.nuget.org/packages/AzureSearchToolkit.
You can also check out the source on https://github.com/nkovacic/AzureSearchToolkit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With