Skip to content

Commit eea8289

Browse files
authored
Merge pull request #36 from trenoncourt/develop
Update to version 1.5.0
2 parents 9ce4b0d + 4777718 commit eea8289

File tree

10 files changed

+143
-24
lines changed

10 files changed

+143
-24
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ In a filter, comma separator is used for OR (eg: color=red,black is translated b
107107
*Note that filters works with primitive types, string, datetime & guid*
108108

109109
## Selection
110+
- Select all properties of level zero without relations: [/products?**select=_**](/products?**select=_)
111+
- Select all properties of level zero with relations: [/products?**select=\***](/products?**select=\*)
110112
- Select an object with all its value types: [/products?**select=productcategory**](/products?select=productcategory)
111113
- Select an object with all its values including navigation properties on the first level: [/products?**select=productcategory.\***](/products?select=productcategory.*)
112114

sample/AutoQueryable.Sample.EfCore/AutoQueryable.Sample.EfCore.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
<PackageId>AutoQueryable.Sample.EfCore</PackageId>
88
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
99
</PropertyGroup>
10-
<ItemGroup>
11-
<ProjectReference Include="..\..\src\AutoQueryable.AspNetCore.Filter\AutoQueryable.AspNetCore.Filter.csproj" />
12-
</ItemGroup>
1310
<ItemGroup>
1411
<PackageReference Include="Dapper" Version="1.50.2" />
1512
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="1.1.2" />
@@ -20,4 +17,7 @@
2017
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.1" />
2118
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="1.1.1" />
2219
</ItemGroup>
20+
<ItemGroup>
21+
<ProjectReference Include="..\..\src\AutoQueryable.AspNetCore.Filter\AutoQueryable.AspNetCore.Filter.csproj" />
22+
</ItemGroup>
2323
</Project>

src/AutoQueryable.AspNet.Filter/AutoQueryable.AspNet.Filter.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<PropertyGroup>
44
<Description>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net &gt;=4.6.</Description>
55
<AssemblyTitle>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net &gt;=4.6.</AssemblyTitle>
6-
<VersionPrefix>1.4.0</VersionPrefix>
7-
<Version>1.4.0</Version>
6+
<VersionPrefix>1.5.0</VersionPrefix>
7+
<Version>1.5.0</Version>
88
<Authors>Thibaut Renoncourt</Authors>
99
<TargetFramework>net46</TargetFramework>
1010
<AssemblyName>AutoQueryable.AspNet.Filter</AssemblyName>

src/AutoQueryable.AspNetCore.Filter/AutoQueryable.AspNetCore.Filter.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<PropertyGroup>
44
<Description>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net Core.</Description>
55
<AssemblyTitle>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Asp.Net Core.</AssemblyTitle>
6-
<VersionPrefix>1.4.0</VersionPrefix>
7-
<Version>1.4.0</Version>
6+
<VersionPrefix>1.5.0</VersionPrefix>
7+
<Version>1.5.0</Version>
88
<Authors>Thibaut Renoncourt</Authors>
99
<TargetFramework>netstandard1.6</TargetFramework>
1010
<AssemblyName>AutoQueryable.AspNetCore.Filter</AssemblyName>
@@ -19,12 +19,12 @@
1919
</PropertyGroup>
2020

2121
<ItemGroup>
22-
<ProjectReference Include="..\AutoQueryable\AutoQueryable.csproj" />
22+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="1.1.2" />
23+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="1.1.2" />
2324
</ItemGroup>
2425

2526
<ItemGroup>
26-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="1.1.2" />
27-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="1.1.2" />
27+
<ProjectReference Include="..\AutoQueryable\AutoQueryable.csproj" />
2828
</ItemGroup>
2929

3030
</Project>

src/AutoQueryable.Core/AutoQueryable.Core.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>netstandard1.3</TargetFrameworks>
4-
<VersionPrefix>1.4.0</VersionPrefix>
5-
<Version>1.4.0</Version>
6-
<AssemblyVersion>1.4.0.0</AssemblyVersion>
7-
<FileVersion>1.4.0.0</FileVersion>
4+
<VersionPrefix>1.5.0</VersionPrefix>
5+
<Version>1.5.0</Version>
6+
<AssemblyVersion>1.5.0.0</AssemblyVersion>
7+
<FileVersion>1.5.0.0</FileVersion>
88
</PropertyGroup>
99
<ItemGroup>
1010
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />

src/AutoQueryable.Nancy.Filter/AutoQueryable.Nancy.Filter.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<TargetFramework>netstandard1.6</TargetFramework>
55
<Description>AutoQueryable.AspNetCore.Filter add filterAttribute for AutoQueryable to Nancy.</Description>
66
<Authors>Thibaut Renoncourt</Authors>
7-
<VersionPrefix>1.4.0</VersionPrefix>
8-
<Version>1.4.0</Version>
7+
<VersionPrefix>1.5.0</VersionPrefix>
8+
<Version>1.5.0</Version>
99
<PackageLicenseUrl>https://raw.githubusercontent.com/trenoncourt/AutoQueryable/master/LICENSE</PackageLicenseUrl>
1010
<PackageProjectUrl>https://github.com/trenoncourt/AutoQueryable</PackageProjectUrl>
1111
<PackageTags>AutoQueryable;AutoQuery;OData;GraphQL</PackageTags>

src/AutoQueryable.Providers.OData/AutoQueryable.Providers.OData.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>netstandard1.3</TargetFramework>
4-
<VersionPrefix>1.4.0</VersionPrefix>
5-
<Version>1.4.0</Version>
6-
<AssemblyVersion>1.4.0.0</AssemblyVersion>
7-
<FileVersion>1.4.0.0</FileVersion>
4+
<VersionPrefix>1.5.0</VersionPrefix>
5+
<Version>1.5.0</Version>
6+
<AssemblyVersion>1.5.0.0</AssemblyVersion>
7+
<FileVersion>1.5.0.0</FileVersion>
88
</PropertyGroup>
99
<ItemGroup>
1010
<ProjectReference Include="..\AutoQueryable.Core\AutoQueryable.Core.csproj" />

src/AutoQueryable/AutoQueryable.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<Description>AutoQueryable add auto querying functionality like OData with best url practices to Asp.Net Core.</Description>
44
<AssemblyTitle>AutoQueryable add auto querying functionality like OData with best url practices to Asp.Net Core.</AssemblyTitle>
5-
<VersionPrefix>1.4.1</VersionPrefix>
5+
<VersionPrefix>1.5.0</VersionPrefix>
66
<Authors>Thibaut Renoncourt</Authors>
77
<TargetFrameworks>netstandard1.3</TargetFrameworks>
88
<AssemblyName>AutoQueryable</AssemblyName>
@@ -14,9 +14,9 @@
1414
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
1515
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
1616
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
17-
<Version>1.4.1</Version>
18-
<AssemblyVersion>1.4.1.0</AssemblyVersion>
19-
<FileVersion>1.4.1.0</FileVersion>
17+
<Version>1.5.0</Version>
18+
<AssemblyVersion>1.5.0.0</AssemblyVersion>
19+
<FileVersion>1.5.0.0</FileVersion>
2020
</PropertyGroup>
2121
<ItemGroup>
2222
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />

src/AutoQueryable/Providers/Default/DefaultColumnProvider.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ public IEnumerable<SelectColumn> GetSelectableColumns(Clauses clauses, AutoQuery
2121
List<SelectColumn> allSelectColumns = new List<SelectColumn>();
2222
List<SelectColumn> selectColumns = new List<SelectColumn>();
2323
var selection = clauses.Select.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList();
24+
var basePropertySelection = selection.Find(s => s == "_");
25+
if (basePropertySelection != null)
26+
{
27+
selection.Remove(basePropertySelection);
28+
selection.AddRange(GetSelectableColumns(profile, entityType).Where(c => !selection.Contains(c, StringComparer.OrdinalIgnoreCase)));
29+
}
30+
var allPropertySelection = selection.Find(s => s == "*");
31+
if (allPropertySelection != null)
32+
{
33+
selection.Remove(basePropertySelection);
34+
selection.AddRange(GetSelectableColumns(profile, entityType, SelectInclusingType.IncludeAllProperties).Where(c => !selection.Contains(c, StringComparer.OrdinalIgnoreCase)));
35+
}
36+
2437
var selectionWithColumnPath = new List<string[]>();
2538
foreach (string selectionItem in selection)
2639
{

test/AutoQueryable.UnitTest/SelectTest.cs

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,110 @@ public void CountWithNullForeignKey()
692692
Assert.AreEqual(query.Count(), DataInitializer.ProductSampleCount);
693693
}
694694
}
695+
696+
[TestMethod]
697+
public void SelectAllPropertiesWithoutRelations()
698+
{
699+
using (AutoQueryableContext context = new AutoQueryableContext())
700+
{
701+
DataInitializer.InitializeSeed(context);
702+
var query = context.Product.AutoQueryable("select=_") as IQueryable<object>;
703+
PropertyInfo[] properties = query.First().GetType().GetProperties();
704+
705+
Assert.AreEqual(17, properties.Count());
706+
707+
Assert.IsTrue(properties.Any(p => p.Name == "ProductId"));
708+
Assert.IsTrue(properties.Any(p => p.Name == "Name"));
709+
Assert.IsTrue(properties.Any(p => p.Name == "ProductNumber"));
710+
Assert.IsTrue(properties.Any(p => p.Name == "Color"));
711+
Assert.IsTrue(properties.Any(p => p.Name == "StandardCost"));
712+
Assert.IsTrue(properties.Any(p => p.Name == "ListPrice"));
713+
Assert.IsTrue(properties.Any(p => p.Name == "Size"));
714+
Assert.IsTrue(properties.Any(p => p.Name == "Weight"));
715+
Assert.IsTrue(properties.Any(p => p.Name == "ProductCategoryId"));
716+
Assert.IsTrue(properties.Any(p => p.Name == "ProductModelId"));
717+
Assert.IsTrue(properties.Any(p => p.Name == "SellStartDate"));
718+
Assert.IsTrue(properties.Any(p => p.Name == "SellEndDate"));
719+
Assert.IsTrue(properties.Any(p => p.Name == "DiscontinuedDate"));
720+
Assert.IsTrue(properties.Any(p => p.Name == "ThumbNailPhoto"));
721+
Assert.IsTrue(properties.Any(p => p.Name == "ThumbnailPhotoFileName"));
722+
Assert.IsTrue(properties.Any(p => p.Name == "Rowguid"));
723+
Assert.IsTrue(properties.Any(p => p.Name == "ModifiedDate"));
724+
725+
Assert.AreEqual(query.Count(), DataInitializer.ProductSampleCount);
726+
}
727+
}
728+
729+
[TestMethod]
730+
public void SelectAllPropertiesWithOneRelation()
731+
{
732+
using (AutoQueryableContext context = new AutoQueryableContext())
733+
{
734+
DataInitializer.InitializeSeed(context);
735+
var query = context.Product.AutoQueryable("select=_,ProductModel") as IQueryable<object>;
736+
PropertyInfo[] properties = query.First().GetType().GetProperties();
737+
738+
Assert.AreEqual(18, properties.Count());
739+
740+
Assert.IsTrue(properties.Any(p => p.Name == "ProductId"));
741+
Assert.IsTrue(properties.Any(p => p.Name == "Name"));
742+
Assert.IsTrue(properties.Any(p => p.Name == "ProductNumber"));
743+
Assert.IsTrue(properties.Any(p => p.Name == "Color"));
744+
Assert.IsTrue(properties.Any(p => p.Name == "StandardCost"));
745+
Assert.IsTrue(properties.Any(p => p.Name == "ListPrice"));
746+
Assert.IsTrue(properties.Any(p => p.Name == "Size"));
747+
Assert.IsTrue(properties.Any(p => p.Name == "Weight"));
748+
Assert.IsTrue(properties.Any(p => p.Name == "ProductCategoryId"));
749+
Assert.IsTrue(properties.Any(p => p.Name == "ProductModelId"));
750+
Assert.IsTrue(properties.Any(p => p.Name == "SellStartDate"));
751+
Assert.IsTrue(properties.Any(p => p.Name == "SellEndDate"));
752+
Assert.IsTrue(properties.Any(p => p.Name == "DiscontinuedDate"));
753+
Assert.IsTrue(properties.Any(p => p.Name == "ThumbNailPhoto"));
754+
Assert.IsTrue(properties.Any(p => p.Name == "ThumbnailPhotoFileName"));
755+
Assert.IsTrue(properties.Any(p => p.Name == "Rowguid"));
756+
Assert.IsTrue(properties.Any(p => p.Name == "ModifiedDate"));
757+
Assert.IsTrue(properties.Any(p => p.Name == "ProductModel"));
758+
759+
Assert.AreEqual(query.Count(), DataInitializer.ProductSampleCount);
760+
}
761+
}
762+
763+
[TestMethod]
764+
public void SelectAllPropertiesFromLevelZero()
765+
{
766+
using (AutoQueryableContext context = new AutoQueryableContext())
767+
{
768+
DataInitializer.InitializeSeed(context);
769+
var query = context.Product.AutoQueryable("select=*") as IQueryable<object>;
770+
PropertyInfo[] properties = query.First().GetType().GetProperties();
771+
772+
Assert.AreEqual(21, properties.Count());
773+
774+
Assert.IsTrue(properties.Any(p => p.Name == "ProductId"));
775+
Assert.IsTrue(properties.Any(p => p.Name == "Name"));
776+
Assert.IsTrue(properties.Any(p => p.Name == "ProductNumber"));
777+
Assert.IsTrue(properties.Any(p => p.Name == "Color"));
778+
Assert.IsTrue(properties.Any(p => p.Name == "StandardCost"));
779+
Assert.IsTrue(properties.Any(p => p.Name == "ListPrice"));
780+
Assert.IsTrue(properties.Any(p => p.Name == "Size"));
781+
Assert.IsTrue(properties.Any(p => p.Name == "Weight"));
782+
Assert.IsTrue(properties.Any(p => p.Name == "ProductCategoryId"));
783+
Assert.IsTrue(properties.Any(p => p.Name == "ProductModelId"));
784+
Assert.IsTrue(properties.Any(p => p.Name == "SellStartDate"));
785+
Assert.IsTrue(properties.Any(p => p.Name == "SellEndDate"));
786+
Assert.IsTrue(properties.Any(p => p.Name == "DiscontinuedDate"));
787+
Assert.IsTrue(properties.Any(p => p.Name == "ThumbNailPhoto"));
788+
Assert.IsTrue(properties.Any(p => p.Name == "ThumbnailPhotoFileName"));
789+
Assert.IsTrue(properties.Any(p => p.Name == "Rowguid"));
790+
Assert.IsTrue(properties.Any(p => p.Name == "ModifiedDate"));
791+
Assert.IsTrue(properties.Any(p => p.Name == "SalesOrderDetail"));
792+
Assert.IsTrue(properties.Any(p => p.Name == "ProductExtension"));
793+
Assert.IsTrue(properties.Any(p => p.Name == "ProductCategory"));
794+
Assert.IsTrue(properties.Any(p => p.Name == "ProductModel"));
795+
796+
Assert.AreEqual(query.Count(), DataInitializer.ProductSampleCount);
797+
}
798+
}
695799
}
696800

697801
}

0 commit comments

Comments
 (0)