The OData Query String Generator is a library designed to generate query string parameters for OData APIs using objects and LINQ expressions. It was originally developed for use with the Azure Cognitive Search engine, which leverages the Elastic Search engine.
- Generate OData query strings dynamically using LINQ expressions.
- Supports complex queries, including nested collections and logical operators.
- Handles various data types, including
DateTime,Guid, and nullable types. - Designed to work seamlessly with Azure Cognitive Search and other OData-compliant APIs.
- .NET Standard 2.0 or higher.
- .NET Framework 4.8 for testing.
Clone the repository and include the ODataGenerator project in your solution.
git clone <repository-url>- Add a reference to the
ODataGeneratorproject in your solution. - Use the
FilterGenerator<T>class to generate OData query strings.
using ODataGenerator;
using System;
var filterGenerator = new FilterGenerator<Record>();
var query = filterGenerator.Generate(record => record.Status == Status.Active && record.Number > 100);
Console.WriteLine(query); // Outputs: "Status eq 0 and Number gt 100"The project includes a comprehensive test suite in the ODataGeneratorTests project. To run the tests:
- Open the solution in Visual Studio.
- Build the solution.
- Run the tests using the Test Explorer.
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Azure Cognitive Search
- Elastic Search
For more information, please refer to the official OData documentation: https://www.odata.org/