Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
<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="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.2.1" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20" />
<PackageVersion Include="Microsoft.VisualStudioEng.MicroBuild.Core" Version="1.0.0" />
</ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions Microsoft.FluentUI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ 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.ODataAdapter", "src\Extensions\DataGrid.ODataAdapter\Microsoft.FluentUI.AspNetCore.Components.DataGrid.ODataAdapter.csproj", "{AFFDA282-83AB-44FA-B400-C935BBFE3308}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -95,6 +97,10 @@ 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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -117,6 +123,7 @@ 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}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {420693A7-C2FD-498C-8E78-4B65CC25389A}
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.ODataAdapter</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.ODataAdapter;
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.ODataAdapter/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.ODataAdapter;

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(((DataServiceQuery<T>)queryable.Take(0)).IncludeCount(), 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).ExecuteAsync(cancellationToken);
}
}
39 changes: 39 additions & 0 deletions src/Extensions/DataGrid.ODataAdapter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## About
Use this package if the data you want to display in the `FluentDataGrid` (component in the `Microsoft.FluentUI.AspNetCore.Components library`) comes from [Microsoft.OData.Client](https://www.nuget.org/packages/Microsoft.OData.Client).

Microsoft OData Client library's DataServiceContext gives you a DataServiceQuery property for each resource in your OData service endpoint. Simply supply this as the grid's RowsData parameter:
```
@inject DataServiceContext MyServiceContext

<FluentDataGrid RowsData="@MyServiceContext.People">
...
</FluentDataGrid>
```

You may also use any DataServiceQuery-supported LINQ operator to filter the data before passing it:
```
@inject DataServiceContext MyServiceContext

<FluentDataGrid RowsData="@MyServiceContext.Documents.Where(d => d.CategoryId == currentCategoryId)">
...
</FluentDataGrid>
```

The `FluentDataGrid` recognizes DataServiceQuery-supplied `IQueryable` instances and knows how to resolve queries asynchronously for efficiency.

## Installation
Install the package by running the command:
```
dotnet add package Microsoft.FluentUI.AspNetCore.Components.DataGrid.ODataAdapter
```

## Usage
In your Program.cs file you need to add the following:
```
builder.Services.AddDataGridODataAdapter();
```

## Support
The Microsoft Fluent UI Blazor library is an open source project and is **not** an official part of ASP.NET Core, which means it’s **not** officially
supported and isn’t committed to ship updates as part of any official .NET updates. It is built and maintained by Microsoft employees (**and** other contributors)
and offers support, like most other open source projects, on a best effort base through the GitHub repository **only**.
Loading