LINQ-enabled client API for issuing OData queries and consuming OData JSON payloads. Supports OData v4 and v4.01. Targets .NET 8 or above. OData .NET library is open source at http://github.com/OData/odata.net. Documentation for the library can be found at https://docs.microsoft.com/en-us/odata/.
$ dotnet add package Microsoft.OData.ClientThe Microsoft.OData.Client library allows you to consume data from and interact with OData services from .NET applications. It provides LINQ-enabled client APIs for issuing OData queries and constructing and consuming OData JSON payloads. It supports OData v4 and v4.01.
You can install the Microsoft.OData.Client package via NuGet:
dotnet add package Microsoft.OData.Client
Or via the NuGet Package Manager Console:
Install-Package Microsoft.OData.Client
To create an OData client, you can use the OData Connected Service in Visual Studio to generate strongly-typed client code for your OData service.
Install the OData Connected Service extension:
Extensions menu in Visual Studio.Manage Extensions.OData Connected Service and install it.Add the OData Connected Service to your project:
Here's a simple example of how to use the generated client to interact with an OData service:
using Microsoft.OData.SampleService.Models.TripPin;
var serviceUri = new Uri("https://services.odata.org/V4/TripPinServiceRW/");
var context = new DefaultContainer(serviceUri);
// Querying data
var people = await context.People.ExecuteAsync();
foreach (var person in people)
{
Console.WriteLine($"{person.FirstName} {person.LastName}");
}
For more detailed information, please refer to the official documentation
There are many ways for you to contribute to OData .NET. The easiest way is to participate in discussion of features and issues. You can also contribute by sending pull requests of features or bug fixes to us. Contribution to the documentations is also highly welcomed. Please refer to the CONTRIBUTING.md for more details.
Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.