![]() |
VOOZH | about |
dotnet add package OData2Linq --version 2.2.1
NuGet\Install-Package OData2Linq -Version 2.2.1
<PackageReference Include="OData2Linq" Version="2.2.1" />
<PackageVersion Include="OData2Linq" Version="2.2.1" />Directory.Packages.props
<PackageReference Include="OData2Linq" />Project file
paket add OData2Linq --version 2.2.1
#r "nuget: OData2Linq, 2.2.1"
#:package OData2Linq@2.2.1
#addin nuget:?package=OData2Linq&version=2.2.1Install as a Cake Addin
#tool nuget:?package=OData2Linq&version=2.2.1Install as a Cake Tool
Apply an OData text query (filter, order by, select, ..) to an IQueryable expression.
| Params | In Memory Collections | Entity Framework | CosmosDB SQL API |
|---|---|---|---|
| $filter | + | + | + |
| $orderby | + | + | + |
| $select | + | + | - |
| $expand | + | + | - |
| $top | + | + | + |
| $skip | + | + | + |
Please check samples below to get started
https://dotnetfiddle.net/6dLB2g
using System;
using System.Linq;
using OData2Linq;
public class Entity
{
public int Id { get; set; }
public string Name { get; set; }
}
public static class GetStartedDemo
{
public static void Demo()
{
Entity[] items =
{
new Entity { Id = 1, Name = "n1" },
new Entity { Id = 2, Name = "n2" },
new Entity { Id = 3, Name = "n3" }
};
IQueryable<Entity> query = items.AsQueryable();
var result = query.OData().Filter("Id eq 1 or Name eq 'n3'").OrderBy("Name desc").TopSkip("10", "0").ToArray();
// Id: 3 Name: n3
// Id: 1 Name: n1
foreach (Entity entity in result)
{
Console.WriteLine("Id: {0} Name: {1}", entity.Id, entity.Name);
}
}
}
Use .ToOriginalQuery() after finishing working with OData to be able to support provider specific methods of original query.
Student[] array = await dbContext.Students.OData()
.Filter("LastName eq 'Alexander' or FirstMidName eq 'Laura'")
.OrderBy("EnrollmentDate desc")
.TopSkip("1","1")
.ToOriginalQuery() // required to be able to use .ToArrayAsync() next.
.ToArrayAsync();
ISelectExpandWrapper[] select2 = await dbContext.Students.OData()
.Filter("LastName eq 'Alexander' or FirstMidName eq 'Laura'")
.OrderBy("EnrollmentDate desc")
.SelectExpandAsQueryable("LastName", "Enrollments($select=CourseId)") //.SelectExpandAsQueryable() use .ToOriginalQuery() implicitly, so not need to call it.
.ToArrayAsync()
var item = await Container.GetItemLinqQueryable<TestEntity>().OData()
.Filter($"Id eq '{id1}'")
.TopSkip("1")
.ToOriginalQuery() // required to be able to use .ToFeedIterator() next.
.ToFeedIterator()
.ReadNextAsync()
See the Wiki pages
Please feel free to create issues and pull requests to the main branch.
| Package | NuGet | Info |
|---|---|---|
| OData2Linq | 👁 NuGet Version |
OData v8 support |
| Community.OData.Linq.Json | 👁 NuGet Version |
Still works on odata v7 libraries. Open an issue to create a new package for odata v8. |
| Community.OData.Linq.AspNetCore | 👁 NuGet Version |
Still works on odata v7 libraries. Open an issue to create a new package for odata v8. |
This project is based on the following project: https://github.com/IharYakimush/comminity-data-odata-linq
This project extends functionality of: https://github.com/OData/AspNetCoreOData
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 2 NuGet packages that depend on OData2Linq:
| Package | Downloads |
|---|---|
|
Aguacongas.IdentityServer
TheIdServer IndentityServer4 abstraction and extensions. |
|
|
Microsoft.SemanticKernel.Plugins.StructuredData.EntityFramework
Semantic Kernel Entity Framework 6.5 plugin for structured data access and manipulation using Entity Framework. Enables AI interactions with relational databases through Entity Framework contexts. |
Showing the top 2 popular GitHub repositories that depend on OData2Linq:
| Repository | Stars |
|---|---|
|
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
|
|
|
Aguafrommars/TheIdServer
OpenID/Connect, OAuth2, WS-Federation and SAML 2.0 server based on Duende IdentityServer and ITFoxtec Identity SAML 2.0 with its admin UI
|