Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #32 from PandaTechAM/development
Browse files Browse the repository at this point in the history
Fix conversion issue related to ICollection and return enum without p…
  • Loading branch information
ruboarm authored May 24, 2024
2 parents 45b3eed + c2ff590 commit 501be55
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/EFCoreQueryMagic/EFCoreQueryMagic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<Authors>PandaTech</Authors>
<Copyright>MIT</Copyright>
<Version>1.0.11</Version>
<Version>1.0.12</Version>
<PackageId>Pandatech.EFCoreQueryMagic</PackageId>
<Title>Pandatech.EFCoreQueryMagic: Dynamic Query and Filter Generator for EF Core</Title>
<Description>Unlock the full potential of your Entity Framework Core applications with Pandatech.EFCoreQueryMagic. This innovative package empowers developers to seamlessly create dynamic, complex queries and filters for SQL tables without diving deep into the intricacies of LINQ or manual query construction. Designed to enhance productivity and maintainability, EFCoreQueryMagic automates the translation of front-end filter requests into optimized, ready-to-execute EF Core queries. Embrace the magic of streamlined data retrieval and manipulation, and elevate your applications to new heights of efficiency and performance.</Description>
Expand Down
30 changes: 10 additions & 20 deletions src/EFCoreQueryMagic/Extensions/DistinctColumnValuesExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,11 @@ private static DistinctColumnValues DistinctColumnValuesGeneral<TModel>(this IQu
.Where(x => (x as Enum)!.HasAttributeOfType<HideEnumValueAttribute>())
.ToList();

if (excludedValues.Count != 0)
{
queried = query3.ToList().Where(x => !excludedValues.Contains(x)).Skip(pageSize * (page - 1))
.Take(pageSize).ToList();
}
else
{
queried = query3.ToList().Skip(pageSize * (page - 1))
.Take(pageSize).ToList();
}
queried = query3.ToList()
.Where(x => !excludedValues.Contains(x))
// .Skip(pageSize * (page - 1))
// .Take(pageSize)
.ToList();
}
else
{
Expand Down Expand Up @@ -277,16 +272,11 @@ private static async Task<DistinctColumnValues> DistinctColumnValuesGeneralAsync
.Where(x => (x as Enum)!.HasAttributeOfType<HideEnumValueAttribute>())
.ToList();

if (excludedValues.Count != 0)
{
queried = query3.ToList().Where(x => !excludedValues.Contains(x)).Skip(pageSize * (page - 1))
.Take(pageSize).ToList();
}
else
{
queried = query3.ToList().Skip(pageSize * (page - 1))
.Take(pageSize).ToList();
}
queried = query3.ToList()
.Where(x => !excludedValues.Contains(x))
// .Skip(pageSize * (page - 1))
// .Take(pageSize)
.ToList();
}
else
{
Expand Down
5 changes: 1 addition & 4 deletions src/EFCoreQueryMagic/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@ public static Type GetCollectionType(this Type requestType)
if (requestType.IsArray)
return requestType.GetElementType()!;

if (requestType.IsGenericType && requestType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
if (requestType.IsGenericType && requestType.GetGenericTypeDefinition().IsIEnumerable())
return requestType.GetGenericArguments()[0];

/*if (requestType.IsGenericType && requestType.GetGenericTypeDefinition() == typeof(Nullable<>))
return requestType.GetGenericArguments()[0];*/

if (requestType.IsGenericType && requestType.GetGenericTypeDefinition() == typeof(List<>))
return requestType.GetGenericArguments()[0];

return requestType;
}

Expand Down
2 changes: 1 addition & 1 deletion src/EFCoreQueryMagic/Helpers/PropertyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static string GetPropertyLambda(MappedToPropertyAttribute propertyAttribu
public static Type GetPropertyType(Type modelType, MappedToPropertyAttribute propertyAttribute)
{
if (propertyAttribute.Encrypted) return typeof(byte[]);

var propertyType = modelType.GetProperty(propertyAttribute.TargetPropertyName)?.PropertyType;

if (propertyType is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public async Task TestDistinctColumnValuesAsync_WithValue()
};

var test = _context.Categories
.Include(x => x.Customers);
.Include(x => x.Customers)
.AsQueryable();

var result = await test
.DistinctColumnValuesAsync(qString.Filters, nameof(CategoryFilter.BirthDay), 20, 1, _context);
Expand Down

0 comments on commit 501be55

Please sign in to comment.