Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
OData client implementation for IAsyncQueryExecutor
  • Loading branch information
miguelhasse committed Oct 15, 2024
commit 2f1664adbbdc93ea6fc3034ea56fe0876bfa8b50
7 changes: 5 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
<PackageVersion Include="bunit" Version="1.31.3" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="xunit" Version="2.9.0" />
<PackageVersion Include="Moq" Version="4.20.70" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<!-- Shared dependencies -->
<PackageVersion Include="Markdig.Signed" Version="0.34.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageVersion Include="Microsoft.OData.Client" Version="8.0.2" />
<PackageVersion Include="Microsoft.OData.Extensions.Client" Version="1.0.6" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20" />
<PackageVersion Include="Microsoft.VisualStudioEng.MicroBuild.Core" Version="1.0.0" />
</ItemGroup>
Expand Down Expand Up @@ -65,4 +68,4 @@
<PackageVersion Include="System.Text.Encodings.Web" Version="$(RuntimeVersion9)" />
<PackageVersion Include="System.Text.Json" Version="$(RuntimeVersion9)" />
</ItemGroup>
</Project>
</Project>
14 changes: 14 additions & 0 deletions Microsoft.FluentUI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentUI.Demo.AssetExplorer
EndProject
Project("{54A90642-561A-4BB1-A94E-469ADEE60C69}") = "Microsoft.FluentUI.AspNetCore.Components.Assets", "src\Core.Assets\Microsoft.FluentUI.AspNetCore.Components.Assets.esproj", "{292081C2-5076-467C-AEFF-12DC0617531A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.FluentUI.AspNetCore.Components.DataGrid.OData.Client", "src\Extensions\DataGrid.OData.Client\Microsoft.FluentUI.AspNetCore.Components.DataGrid.OData.Client.csproj", "{AFFDA282-83AB-44FA-B400-C935BBFE3308}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.FluentUI.AspNetCore.Components.DataGrid.OData.Client.Tests", "tests\Extensions\DataGrid.OData.Client\Microsoft.FluentUI.AspNetCore.Components.DataGrid.OData.Client.Tests.csproj", "{4EA8E433-29AC-495D-B34C-834EB9DB11D7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -95,6 +99,14 @@ Global
{292081C2-5076-467C-AEFF-12DC0617531A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{292081C2-5076-467C-AEFF-12DC0617531A}.Release|Any CPU.Build.0 = Release|Any CPU
{292081C2-5076-467C-AEFF-12DC0617531A}.Release|Any CPU.Deploy.0 = Release|Any CPU
{AFFDA282-83AB-44FA-B400-C935BBFE3308}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFFDA282-83AB-44FA-B400-C935BBFE3308}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFFDA282-83AB-44FA-B400-C935BBFE3308}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFFDA282-83AB-44FA-B400-C935BBFE3308}.Release|Any CPU.Build.0 = Release|Any CPU
{4EA8E433-29AC-495D-B34C-834EB9DB11D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4EA8E433-29AC-495D-B34C-834EB9DB11D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4EA8E433-29AC-495D-B34C-834EB9DB11D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4EA8E433-29AC-495D-B34C-834EB9DB11D7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -117,6 +129,8 @@ Global
{17F26C55-E329-4117-B64D-0393E912FFFE} = {9468ADD1-3660-410D-8231-6F89384D135D}
{E4E62EAA-38FC-48FE-B63E-EB4ABAD660D2} = {17F26C55-E329-4117-B64D-0393E912FFFE}
{292081C2-5076-467C-AEFF-12DC0617531A} = {DF88C07D-46D7-4DEC-ACE4-409217634E57}
{AFFDA282-83AB-44FA-B400-C935BBFE3308} = {1199ECBA-EE19-44CD-A471-85AB2F44489C}
{4EA8E433-29AC-495D-B34C-834EB9DB11D7} = {EBE3ACB2-9B23-4F91-9953-7153E3D2B0DA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {420693A7-C2FD-498C-8E78-4B65CC25389A}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3517,6 +3517,7 @@
Gets or sets the dialog position:
left (full height), right (full height)
or screen middle (using Width and Height properties).
HorizontalAlignment.Stretch is not supported for this property.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.DialogParameters.Title">
Expand Down Expand Up @@ -13869,6 +13870,11 @@
The content is aligned to the end.
</summary>
</member>
<member name="F:Microsoft.FluentUI.AspNetCore.Components.HorizontalAlignment.Stretch">
<summary>
The content is stretched to fill the available space.
</summary>
</member>
<member name="T:Microsoft.FluentUI.AspNetCore.Components.HorizontalPosition">
<summary>
Describes the horizontal positioning of a <see cref="T:Microsoft.FluentUI.AspNetCore.Components.FluentAnchoredRegion"/>.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<PackageId>Microsoft.FluentUI.AspNetCore.Components.DataGrid.OData.Client</PackageId>
<Authors>Microsoft</Authors>
<Copyright>Β© Microsoft Corporation. All rights reserved.</Copyright>
<NeutralLanguage>en</NeutralLanguage>
<Owners>Microsoft Corporation</Owners>
<PackageProjectUrl>https://github.com/microsoft/fluentui-blazor</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Summary>An adapter for using the Fluent UI Blazor DataGrid with OData Client.</Summary>
<PackageTags>Fluent UI, Blazor, DataGrid, .NET8</PackageTags>
<Title>Microsoft Fluent UI DataGrid adapter for Entity Framework</Title>
<Description>An adapter for using the Fluent UI Blazor DataGrid with OData Client.</Description>
<SignAssembly>false</SignAssembly>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DebugType>embedded</DebugType>
<EmbedUntrackedSources>true</EmbedUntrackedSources>

<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>https://github.com/microsoft/fluentui-blazor</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageReadmeFile>README.md</PackageReadmeFile>
<LangVersion>latest</LangVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>true</IsPackable>
<PackageIcon>icon.png</PackageIcon>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<IsShipping>true</IsShipping>
<Optimize>True</Optimize>
<NoWarn>1701;1702;8669;1591</NoWarn>
<DebuggerSupport>false</DebuggerSupport>
<TrimmerRemoveSymbols>true</TrimmerRemoveSymbols>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageOutputPath>$(SolutionDir)artifacts</PackageOutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.OData.Client" />
<PackageReference Include="Microsoft.VisualStudioEng.MicroBuild.Core">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Core\Microsoft.FluentUI.AspNetCore.Components.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
<None Include="..\..\..\icon.png" Pack="true" PackagePath="\" />
</ItemGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true' Or '$(TF_BUILD)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.FluentUI.AspNetCore.Components.DataGrid.OData.Client;
using Microsoft.FluentUI.AspNetCore.Components.DataGrid.Infrastructure;

namespace Microsoft.Extensions.DependencyInjection;

/// <summary>
/// Provides extension methods to configure <see cref="IAsyncQueryExecutor"/> on a <see cref="IServiceCollection"/>.
/// </summary>
public static class ODataAdapterServiceCollectionExtensions
{
/// <summary>
/// Registers an OData aware implementation of <see cref="IAsyncQueryExecutor"/>.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
public static void AddDataGridODataAdapter(this IServiceCollection services)
{
services.AddScoped<IAsyncQueryExecutor, ODataAsyncQueryExecutor>();
}
}
20 changes: 20 additions & 0 deletions src/Extensions/DataGrid.OData.Client/ODataAsyncQueryExecutor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.OData.Client;
using Microsoft.FluentUI.AspNetCore.Components.DataGrid.Infrastructure;

namespace Microsoft.FluentUI.AspNetCore.Components.DataGrid.OData.Client;

internal class ODataAsyncQueryExecutor : IAsyncQueryExecutor
{
public bool IsSupported<T>(IQueryable<T> queryable) => queryable.Provider is DataServiceQueryProvider;

public async Task<int> CountAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken)
=> (int)(await ExecuteAsync(queryable, cancellationToken)).Count;

public async Task<T[]> ToArrayAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken)
=> [.. await ExecuteAsync(queryable, cancellationToken)];

private static async Task<QueryOperationResponse<T>> ExecuteAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken)
{
return (QueryOperationResponse<T>)await ((DataServiceQuery<T>)queryable).IncludeCount().ExecuteAsync(cancellationToken);
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Core\Microsoft.FluentUI.AspNetCore.Components.csproj" />
<ProjectReference Include="..\..\..\src\Extensions\DataGrid.OData.Client\Microsoft.FluentUI.AspNetCore.Components.DataGrid.OData.Client.csproj" />
</ItemGroup>

</Project>