Skip to content

Commit

Permalink
fix: Add null support to DateEqualTo
Browse files Browse the repository at this point in the history
  • Loading branch information
bugrakosen committed Oct 31, 2024
1 parent c77d6d1 commit 0399553
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ExpressionBuilder/ExpressionBuilder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</Description>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Version>1.0.12</Version>
<Version>1.0.13</Version>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageId>Milvasoft.ExpressionBuilder</PackageId>
</PropertyGroup>
Expand Down
7 changes: 5 additions & 2 deletions ExpressionBuilder/Operations/DateEqualTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ public DateEqualTo() : base(nameof(DateEqualTo), ValueCount, TypeGroup.Date) { }
/// <inheritdoc />
public override Expression GetExpression(MemberExpression member, ConstantExpression constant1, ConstantExpression constant2)
{
if (!IsDateType(constant1) || constant1.Value == null)
throw new InvalidDataException("DateEqualTo can be used with only date types and cannot be null");
if (!IsDateType(constant1))
throw new InvalidDataException("DateEqualTo can be used with only date types");

if (constant1.Value == null)
return Expression.Equal(member, constant1);

var (startDateExpression, endDateExpression) = GetStartAndEndDates(constant1);

Expand Down

0 comments on commit 0399553

Please sign in to comment.