Skip to content

Commit

Permalink
Merge pull request #43 from Evodim/fixes/Query-extension-In-not-scoped
Browse files Browse the repository at this point in the history
Fixes/query extension in not scoped
  • Loading branch information
medevod authored Feb 10, 2023
2 parents a60c18d + 633cf66 commit 833015d
Show file tree
Hide file tree
Showing 37 changed files with 129 additions and 131 deletions.
28 changes: 14 additions & 14 deletions Azure.EntityServices.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{12E4
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TableClient.PerformanceSample", "samples\TableClient.Performance.Sample\TableClient.PerformanceSample.csproj", "{1AE5DF7B-3328-49B9-A455-D609ACC2BB95}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common.Samples", "Common.Samples\Common.Samples.csproj", "{ADAFA655-104A-4375-BA08-3A8007860B5A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlobClient.BasicSample", "samples\BlobClient.Sample\BlobClient.BasicSample.csproj", "{61ED3E91-9ED3-4D09-A51C-83ABA1F83D75}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TableClient.BasicSample", "samples\TableClient.Basic.Sample\TableClient.BasicSample.csproj", "{5CEB65EF-0D90-493C-9A81-270B3914F3C4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TableClient.LegacySample", "TableClient.Legacy.Sample\TableClient.LegacySample.csproj", "{9DF46286-6193-4A5D-A127-866C76252419}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.EntityServices.Blobs.Extensions.DependencyInjection", "src\Azure.EntityServices.Blobs.Extensions.DependencyInjection\Azure.EntityServices.Blobs.Extensions.DependencyInjection.csproj", "{6D5B1034-2ED7-4EBE-BC4E-6C93CBDCDED6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlobClient.DependencyInjection.Sample", "samples\BlobClient.DependencyInjection.Sample\BlobClient.DependencyInjection.Sample.csproj", "{BAB3206B-D2F7-4790-8629-76D7A33DC969}"
Expand All @@ -47,6 +43,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{D449467E
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B6C4E5FE-96DE-4BDF-9D98-2288E601D08C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common.Samples", "samples\Common.Samples\Common.Samples.csproj", "{9B8845F6-BEDD-4295-8E1B-7831B1246B26}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TableClient.LegacySample", "samples\TableClient.Legacy.Sample\TableClient.LegacySample.csproj", "{9BBE86B6-F1B9-4379-A739-898388CDAA96}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -77,10 +77,6 @@ Global
{1AE5DF7B-3328-49B9-A455-D609ACC2BB95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1AE5DF7B-3328-49B9-A455-D609ACC2BB95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1AE5DF7B-3328-49B9-A455-D609ACC2BB95}.Release|Any CPU.Build.0 = Release|Any CPU
{ADAFA655-104A-4375-BA08-3A8007860B5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADAFA655-104A-4375-BA08-3A8007860B5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADAFA655-104A-4375-BA08-3A8007860B5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADAFA655-104A-4375-BA08-3A8007860B5A}.Release|Any CPU.Build.0 = Release|Any CPU
{61ED3E91-9ED3-4D09-A51C-83ABA1F83D75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{61ED3E91-9ED3-4D09-A51C-83ABA1F83D75}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61ED3E91-9ED3-4D09-A51C-83ABA1F83D75}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -89,10 +85,6 @@ Global
{5CEB65EF-0D90-493C-9A81-270B3914F3C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CEB65EF-0D90-493C-9A81-270B3914F3C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CEB65EF-0D90-493C-9A81-270B3914F3C4}.Release|Any CPU.Build.0 = Release|Any CPU
{9DF46286-6193-4A5D-A127-866C76252419}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9DF46286-6193-4A5D-A127-866C76252419}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DF46286-6193-4A5D-A127-866C76252419}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DF46286-6193-4A5D-A127-866C76252419}.Release|Any CPU.Build.0 = Release|Any CPU
{6D5B1034-2ED7-4EBE-BC4E-6C93CBDCDED6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D5B1034-2ED7-4EBE-BC4E-6C93CBDCDED6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D5B1034-2ED7-4EBE-BC4E-6C93CBDCDED6}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -113,6 +105,14 @@ Global
{321BB55F-AA1C-4973-9315-7323D4FC19B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{321BB55F-AA1C-4973-9315-7323D4FC19B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{321BB55F-AA1C-4973-9315-7323D4FC19B0}.Release|Any CPU.Build.0 = Release|Any CPU
{9B8845F6-BEDD-4295-8E1B-7831B1246B26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B8845F6-BEDD-4295-8E1B-7831B1246B26}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B8845F6-BEDD-4295-8E1B-7831B1246B26}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B8845F6-BEDD-4295-8E1B-7831B1246B26}.Release|Any CPU.Build.0 = Release|Any CPU
{9BBE86B6-F1B9-4379-A739-898388CDAA96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BBE86B6-F1B9-4379-A739-898388CDAA96}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BBE86B6-F1B9-4379-A739-898388CDAA96}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BBE86B6-F1B9-4379-A739-898388CDAA96}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -124,15 +124,15 @@ Global
{4019B11A-8481-4BE3-8B61-01F9FD0AEC5E} = {B6C4E5FE-96DE-4BDF-9D98-2288E601D08C}
{1D6ED178-F026-4F39-9FC2-FBD1EB182B7B} = {B6C4E5FE-96DE-4BDF-9D98-2288E601D08C}
{1AE5DF7B-3328-49B9-A455-D609ACC2BB95} = {12E4FDA9-194D-4758-BB02-1619C2956738}
{ADAFA655-104A-4375-BA08-3A8007860B5A} = {12E4FDA9-194D-4758-BB02-1619C2956738}
{61ED3E91-9ED3-4D09-A51C-83ABA1F83D75} = {12E4FDA9-194D-4758-BB02-1619C2956738}
{5CEB65EF-0D90-493C-9A81-270B3914F3C4} = {12E4FDA9-194D-4758-BB02-1619C2956738}
{9DF46286-6193-4A5D-A127-866C76252419} = {12E4FDA9-194D-4758-BB02-1619C2956738}
{6D5B1034-2ED7-4EBE-BC4E-6C93CBDCDED6} = {B6C4E5FE-96DE-4BDF-9D98-2288E601D08C}
{BAB3206B-D2F7-4790-8629-76D7A33DC969} = {12E4FDA9-194D-4758-BB02-1619C2956738}
{8F8165C7-37ED-42C2-9D8A-BBABB461BCB8} = {12E4FDA9-194D-4758-BB02-1619C2956738}
{C825B333-1737-45F2-ADD3-2BF7D735BB41} = {12E4FDA9-194D-4758-BB02-1619C2956738}
{321BB55F-AA1C-4973-9315-7323D4FC19B0} = {12E4FDA9-194D-4758-BB02-1619C2956738}
{9B8845F6-BEDD-4295-8E1B-7831B1246B26} = {12E4FDA9-194D-4758-BB02-1619C2956738}
{9BBE86B6-F1B9-4379-A739-898388CDAA96} = {12E4FDA9-194D-4758-BB02-1619C2956738}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {92B5DB88-8C8E-4300-8891-C52633DDF5D9}
Expand Down
25 changes: 0 additions & 25 deletions TableClient.Legacy.Sample/TableClient.LegacySample.csproj

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Blobs.Extensions.DependencyInjection\Azure.EntityServices.Blobs.Extensions.DependencyInjection.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Queries\Azure.EntityServices.Queries.csproj" />
<ProjectReference Include="..\..\tests\Azure.EntityServices.Tests\Azure.EntityServices.Tests.csproj" />
<ProjectReference Include="..\Common.Samples\Common.Samples.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion samples/BlobClient.Sample/BlobClient.BasicSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\samples\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Blobs\Azure.EntityServices.Blobs.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Queries\Azure.EntityServices.Queries.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Tables\Azure.EntityServices.Tables.csproj" />
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Blobs\Azure.EntityServices.Blobs.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Tables\Azure.EntityServices.Tables.csproj" />
<ProjectReference Include="..\Common.Samples\Common.Samples.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\samples\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Tables.Extensions.DependencyInjection\Azure.EntityServices.Tables.Extensions.DependencyInjection.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Tables\Azure.EntityServices.Tables.csproj" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\samples\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Tables.Extensions.DependencyInjection\Azure.EntityServices.Tables.Extensions.DependencyInjection.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Tables\Azure.EntityServices.Tables.csproj" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\samples\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Tables.Extensions.DependencyInjection\Azure.EntityServices.Tables.Extensions.DependencyInjection.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Tables\Azure.EntityServices.Tables.csproj" />

Expand Down
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions samples/TableClient.Legacy.Sample/TableClient.LegacySample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.32" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\samples\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Queries\Azure.EntityServices.Queries.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Tables.Extensions.DependencyInjection\Azure.EntityServices.Tables.Extensions.DependencyInjection.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Tables\Azure.EntityServices.Tables.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\samples\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Blobs\Azure.EntityServices.Blobs.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Tables\Azure.EntityServices.Tables.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ protected virtual string Build(IFilterExpression<T> expression)
if (expression.Group.Count > 0)
{
foreach (var operation in expression.Group)
{
{
queryBuilder.Append($" {InstructionsProvider.Get(operation.GroupOperator)} (");
queryBuilder.Append(Build(operation));
queryBuilder.Append(")");
}
}
}
queryBuilder.Append($" {InstructionsProvider.Get(expression.Operator)} ");

queryBuilder.Append(Build(expression.NextOperation));

return queryBuilder.ToString().Trim();
Expand Down
6 changes: 3 additions & 3 deletions src/Azure.EntityServices.Queries/FilterExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public virtual IFilterExpression<T> Factory<P>()
public List<IFilterExpression<T>> Group { get; } = new List<IFilterExpression<T>>();

public IFilterExpression<T> NextOperation { get; set; }
public IFilterExpression<T> LastOperation { get; set; }
public IFilterExpression<T> PrevOperation { get; set; }

public IQueryFilter<T, P> AddOperator<P>(string expressionOperator, Expression<Func<T, P>> property)
{
Expand All @@ -40,7 +40,7 @@ public IQueryFilter<T, P> AddOperator<P>(string expressionOperator, Expression<F

newOperation.PropertyName = prop.Name;
newOperation.PropertyType = prop.PropertyType;
newOperation.LastOperation = this;
newOperation.PrevOperation = this;

NextOperation = newOperation;
return newOperation as IQueryFilter<T,P>;
Expand All @@ -53,7 +53,7 @@ public IQueryFilter<T> AddOperator(string expressionOperator, string property)

newOperation.PropertyName = property;
newOperation.PropertyType = typeof(object);
newOperation.LastOperation = this;
newOperation.PrevOperation = this;

NextOperation = newOperation;
return newOperation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ public static IFilterOperator<T> WithEach<T, U>(this IFilterOperator<T> query, I
public static IFilterOperator<T> NotIn<T, P>(this IQueryFilter<T, P> query, params P[] values)
{
var exp = query as IFilterExpression<T>;

exp.LastOperation.AddGroupExpression(string.IsNullOrEmpty(exp.LastOperation.PropertyName) ? "" : "And",
exp.PrevOperation.AddGroupExpression(string.IsNullOrEmpty(exp.PrevOperation.PropertyName) ? "" : "And",
p => p.Where(exp.PropertyName)
._NotIn(values));

//ignore current expression because we need override and keep the previous expression
exp.PropertyName = null;
exp.Operator = null;

return exp.LastOperation;
exp.PrevOperation.Operator = null;
return exp.PrevOperation;
}
/// <summary>
/// Build a filter to check if current field value was present in given list
Expand All @@ -58,13 +60,15 @@ public static IFilterOperator<T> In<T, P>(this IQueryFilter<T, P> query, params

var exp = query as IFilterExpression<T>;

exp.LastOperation.AddGroupExpression(string.IsNullOrEmpty(exp.LastOperation.PropertyName) ? "" : "And",
exp.PrevOperation.AddGroupExpression(string.IsNullOrEmpty(exp.PrevOperation.PropertyName) ? "" : "And",
p => p.Where(exp.PropertyName)
._In(values));

//ignore current expression because we need override and keep the previous expression
exp.PropertyName = null;
exp.Operator = null;

return exp.LastOperation;
exp.PrevOperation.Operator = null;
return exp.PrevOperation;
}

private static IFilterOperator<T> _In<T, P>(this IQueryFilter<T> query, P[] values)
Expand All @@ -75,7 +79,7 @@ private static IFilterOperator<T> _In<T, P>(this IQueryFilter<T> query, P[] valu
nextQuery = (IQuery<T>)(nextQuery as IQueryFilter<T>)
.Equal(item)
.Or((query as IFilterExpression<T>).PropertyName);
}
}
(nextQuery as IQueryFilter<T>).Equal(values.Last());
return nextQuery as IFilterOperator<T>;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Azure.EntityServices.Queries/IQueryExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public interface IFilterExpression<T> : IFilterOperator<T>, IQueryFilter<T>, IQu
List<IFilterExpression<T>> Group { get; }
public string GroupOperator { get; set; }
IFilterExpression<T> NextOperation { get; set; }
IFilterExpression<T> LastOperation { get; set; }
IFilterExpression<T> PrevOperation { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
Expand All @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\samples\Common.Samples\Common.Samples.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Blobs\Azure.EntityServices.Blobs.csproj" />
<ProjectReference Include="..\..\src\Azure.EntityServices.Tables\Azure.EntityServices.Tables.csproj" />
</ItemGroup>
Expand Down
Loading

0 comments on commit 833015d

Please sign in to comment.