Skip to content

Commit

Permalink
- (Reporting) Fixed issue in attribute Expression Helper that caused …
Browse files Browse the repository at this point in the history
…unnecessary index scans (Fixes SparkDevNetwork#5575)
  • Loading branch information
Jon-Corey committed Sep 6, 2023
1 parent c1560a8 commit 3cac498
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Rock/Utility/ExpressionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ public static Expression GetAttributeExpression( IService serviceInstance, Param
}

var service = new AttributeValueService( ( RockContext ) serviceInstance.Context );
var attributeValues = service.Queryable();

var attributeValues = service.Queryable().Where( v =>
v.EntityId.HasValue );

AttributeCache attributeCache = null;

Expand Down Expand Up @@ -254,7 +256,7 @@ public static Expression GetAttributeExpression( IService serviceInstance, Param
return new NoAttributeFilterExpression();
}

IQueryable<int> ids = attributeValues.Select( v => v.EntityId ?? 0 );
IQueryable<int> ids = attributeValues.Select( v => v.EntityId.Value );

MemberExpression propertyExpression = Expression.Property( parameterExpression, "Id" );
ConstantExpression idsExpression = Expression.Constant( ids.AsQueryable(), typeof( IQueryable<int> ) );
Expand Down

0 comments on commit 3cac498

Please sign in to comment.