Skip to content

Commit

Permalink
Fixed a bug for classes that are sent as null.
Browse files Browse the repository at this point in the history
  • Loading branch information
byerlikaya committed Jul 10, 2024
1 parent 14d143e commit f5e99ed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions src/SmartWhere/SmartWhere.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static IQueryable<T> Where<T>(this IQueryable<T> source, IWhereClause whe
{
var whereClauseProperties = whereClauseDto.GetWhereClauseProperties(out var valueData);

if (whereClauseProperties.IsNullOrNotAny())
if (whereClauseProperties.IsNullOrNotAny() || valueData.IsNull())
return source.Where(x => true);

Expression comparison = null;
Expand Down Expand Up @@ -195,7 +195,6 @@ private static Expression ComplexComparison<T>(

foreach (var (propertyInfo, propertyType) in properties)
{

if (!propertyType.Namespace!.StartsWith("System") ||
propertyInfo.PropertyType!.IsEnumarableType())
{
Expand Down Expand Up @@ -290,9 +289,7 @@ private static MemberExpression SetLastMember(
Expression parameterExpression)
{
if (lastMember.IsNull())
{
return Expression.Property(baseParameter, propertyInfo.Name);
}

return currentType.IsEnumarableType()
? Expression.MakeMemberAccess(parameterExpression, propertyInfo)
Expand All @@ -312,9 +309,7 @@ private static ParameterExpression SetParameterExpression(
ParameterExpression parameterExpression)
{
if (currentType.IsEnumarableType())
{
return Expression.Parameter(type!, type!.Name.ToLower());
}

return parameterExpression.IsNull()
? Expression.Parameter(type, type.Name.ToLower())
Expand Down
2 changes: 1 addition & 1 deletion src/SmartWhere/SmartWhere.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<PackageId>SmartWhere</PackageId>
<Version>2.2.1</Version>
<Version>2.2.2</Version>
<Authors>Barış Yerlikaya</Authors>
<Company>Barış Yerlikaya</Company>
<Product>SmartWhere</Product>
Expand Down

0 comments on commit f5e99ed

Please sign in to comment.