Skip to content

Commit

Permalink
Fixed OData build. (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgernand authored May 27, 2022
1 parent 206aa80 commit 4292785
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
14 changes: 14 additions & 0 deletions Fluxera.Repository.sln
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fluxera.Repository.OpenTele
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApplication1", "tests\WebApplication1\WebApplication1.csproj", "{901E8A8F-DBF2-405D-9C58-813024AF2218}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fluxera.Repository.OData", "src\Fluxera.Repository.OData\Fluxera.Repository.OData.csproj", "{071F8AC6-D6D3-4ABE-AC5D-1EA77C767165}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fluxera.Repository.OData.IntegrationTests", "tests\Fluxera.Repository.OData.IntegrationTests\Fluxera.Repository.OData.IntegrationTests.csproj", "{F2D028DD-F903-403B-92FD-E5963A9F8A6A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -119,6 +123,14 @@ Global
{901E8A8F-DBF2-405D-9C58-813024AF2218}.Debug|Any CPU.Build.0 = Debug|Any CPU
{901E8A8F-DBF2-405D-9C58-813024AF2218}.Release|Any CPU.ActiveCfg = Release|Any CPU
{901E8A8F-DBF2-405D-9C58-813024AF2218}.Release|Any CPU.Build.0 = Release|Any CPU
{071F8AC6-D6D3-4ABE-AC5D-1EA77C767165}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{071F8AC6-D6D3-4ABE-AC5D-1EA77C767165}.Debug|Any CPU.Build.0 = Debug|Any CPU
{071F8AC6-D6D3-4ABE-AC5D-1EA77C767165}.Release|Any CPU.ActiveCfg = Release|Any CPU
{071F8AC6-D6D3-4ABE-AC5D-1EA77C767165}.Release|Any CPU.Build.0 = Release|Any CPU
{F2D028DD-F903-403B-92FD-E5963A9F8A6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2D028DD-F903-403B-92FD-E5963A9F8A6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2D028DD-F903-403B-92FD-E5963A9F8A6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2D028DD-F903-403B-92FD-E5963A9F8A6A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -139,6 +151,8 @@ Global
{29B9954C-0A2C-4D23-8C99-3396DC454FCF} = {F18D2D58-282C-4D93-8D9A-3A76CF98F018}
{44CFEFC2-119D-45FC-985D-528F55888886} = {DF28D730-99B3-4811-AAC7-725A73B3F668}
{901E8A8F-DBF2-405D-9C58-813024AF2218} = {F18D2D58-282C-4D93-8D9A-3A76CF98F018}
{071F8AC6-D6D3-4ABE-AC5D-1EA77C767165} = {DF28D730-99B3-4811-AAC7-725A73B3F668}
{F2D028DD-F903-403B-92FD-E5963A9F8A6A} = {F18D2D58-282C-4D93-8D9A-3A76CF98F018}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D97BF2AF-6E68-4E88-BF70-773A86E26013}
Expand Down
2 changes: 1 addition & 1 deletion src/Fluxera.Repository.OData/ODataRepositoryExtensions.cs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
namespace Fluxera.Repository.OData{ using Fluxera.Repository.Query; using Simple.OData.Client; internal static class ODataRepositoryExtensions { internal static IBoundClient<T> Apply<T>(this IBoundClient<T> client, IQueryOptions<T> options) where T : class { if(options is null) { return client; } if(options.TryGetPagingOptions(out IPagingOptions<T> pagingOptions)) { client = client .Skip(pagingOptions!.Skip) .Top(pagingOptions.PageSize); } if(options.TryGetSkipTakeOptions(out ISkipTakeOptions<T> skipTakeOptions)) { if(skipTakeOptions!.SkipAmount.HasValue) { client = client.Skip(skipTakeOptions.SkipAmount.Value); } if(skipTakeOptions.TakeAmount.HasValue) { client = client.Top(skipTakeOptions.TakeAmount.Value); } } if(options.TryGetSortingOptions(out ISortingOptions<T> orderByOptions)) { ISortExpression<T> primaryExpression = orderByOptions!.PrimaryExpression; IBoundClient<T> orderedClient = primaryExpression.IsDescending ? client.OrderByDescending(primaryExpression.Expression) : client.OrderBy(primaryExpression.Expression); foreach(ISortExpression<T> expression in orderByOptions.SecondaryExpressions) { orderedClient = expression.IsDescending ? orderedClient.ThenBy(expression.Expression) : orderedClient.ThenByDescending(expression.Expression); } client = orderedClient; } return client; } }}
namespace Fluxera.Repository.OData{ using Fluxera.Repository.Query; using Simple.OData.Client; internal static class ODataRepositoryExtensions { internal static IBoundClient<T> Apply<T>(this IBoundClient<T> client, IQueryOptions<T> options) where T : class { if(options is null) { return client; } if(options.TryGetPagingOptions(out IPagingOptions<T> pagingOptions)) { client = client .Skip(pagingOptions!.SkipAmount) .Top(pagingOptions.PageSizeAmount); } if(options.TryGetSkipTakeOptions(out ISkipTakeOptions<T> skipTakeOptions)) { if(skipTakeOptions!.SkipAmount.HasValue) { client = client.Skip(skipTakeOptions.SkipAmount.Value); } if(skipTakeOptions.TakeAmount.HasValue) { client = client.Top(skipTakeOptions.TakeAmount.Value); } } if(options.TryGetSortingOptions(out ISortingOptions<T> orderByOptions)) { ISortExpression<T> primaryExpression = orderByOptions!.PrimaryExpression; IBoundClient<T> orderedClient = primaryExpression.IsDescending ? client.OrderByDescending(primaryExpression.Expression) : client.OrderBy(primaryExpression.Expression); foreach(ISortExpression<T> expression in orderByOptions.SecondaryExpressions) { orderedClient = expression.IsDescending ? orderedClient.ThenBy(expression.Expression) : orderedClient.ThenByDescending(expression.Expression); } client = orderedClient; } return client; } }}
Expand Down
7 changes: 4 additions & 3 deletions src/Fluxera.Repository/Caching/CachingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ internal sealed class CachingProvider : CachingProviderBase
{
// Instantiate a Singleton of the Semaphore with a value of 1.
// This means that only 1 thread can be granted access at a time.
private static readonly SemaphoreSlim semaphore = new SemaphoreSlim(1, 1);
private static readonly SemaphoreSlim Semaphore = new SemaphoreSlim(1, 1);

private readonly IDistributedCache distributedCache;

public CachingProvider(
Expand Down Expand Up @@ -75,7 +76,7 @@ protected override async Task<long> IncrementAsync(string key, long incrementVal
// Asynchronously wait to enter the Semaphore.
// If no-one has been granted access to the Semaphore, code execution will proceed,
// otherwise this thread waits here until the semaphore is released.
await semaphore.WaitAsync();
await Semaphore.WaitAsync();
try
{
long value = await this.GetAsync<long>(key).ConfigureAwait(false);
Expand All @@ -91,7 +92,7 @@ protected override async Task<long> IncrementAsync(string key, long incrementVal
// end up with a Semaphore that is forever locked. This is why it is important to
// do the Release within a try...finally clause; program execution may crash or
// take a different path, this way you are guaranteed execution.
semaphore.Release();
Semaphore.Release();
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/Fluxera.Repository/Caching/CachingStrategyNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@
{
using JetBrains.Annotations;

/// <summary>
/// Class holding constants that represent the available caching strategies.
/// </summary>
[PublicAPI]
public static class CachingStrategyNames
{
/// <summary>
/// No caching strategy.
/// </summary>
public const string NoCaching = "NoCaching";

/// <summary>
/// The standard caching strategy.
/// </summary>
public const string Standard = "Standard";

/// <summary>
/// The timeout caching strategy.
/// </summary>
public const string Timeout = "Timeout";
}
}
4 changes: 2 additions & 2 deletions tests/Fluxera.Repository.UnitTests.Core/SortingTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public virtual async Task ShouldSortByPrimaryAndSecondary()
IReadOnlyCollection<Person> result = await this.PersonRepository.FindManyAsync(x => x.Age < 35, options);
IList<Person> resultList = new List<Person>(result);

IOrderedEnumerable<Person> orderedEnumerable = persons.OrderBy(x => x.Name).ThenBy(x => x.Age);
IOrderedEnumerable<Person> _ = persons.OrderBy(x => x.Name).ThenBy(x => x.Age);

resultList.Count.Should().Be(4);
resultList[0].Name.Should().Be("Arnold");
Expand Down Expand Up @@ -205,7 +205,7 @@ public virtual async Task ShouldSortByPrimaryAndSecondaryDescending()
IReadOnlyCollection<Person> result = await this.PersonRepository.FindManyAsync(x => x.Age < 35, options);
IList<Person> resultList = new List<Person>(result);

IOrderedEnumerable<Person> orderedEnumerable = persons.OrderBy(x => x.Name).ThenBy(x => x.Age);
IOrderedEnumerable<Person> _ = persons.OrderBy(x => x.Name).ThenBy(x => x.Age);

resultList.Count.Should().Be(4);
resultList[3].Name.Should().Be("Arnold");
Expand Down
2 changes: 0 additions & 2 deletions tests/ODataApplication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,3 @@ IEdmModel GetModel()

return model;
}

;
4 changes: 2 additions & 2 deletions tests/WebApplication1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

// Configure important OpenTelemetry settings, the console exporter, and automatic instrumentation
builder.Services.AddOpenTelemetryTracing(builder =>
builder.Services.AddOpenTelemetryTracing(providerBuilder =>
{
builder
providerBuilder
.AddConsoleExporter()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("WebApplication1", "1.0.0"))
.AddHttpClientInstrumentation()
Expand Down

0 comments on commit 4292785

Please sign in to comment.