private bool CheckLocalReBuildRequired(IClearanceSource clearanceSource) { if (!ReferenceEquals(_LastClearanceSource, clearanceSource)) { _LocalFilterExpression = null; _LastClearanceSource = clearanceSource; } var ccDate = _LastClearanceSource.LastClearanceChangeDateUtc; if (ccDate > _ClearanceVersionWithinFilterExpression) { _LocalFilterExpression = null; _ClearanceVersionWithinFilterExpression = ccDate; } if (_LocalFilterExpression != null) { foreach (Type relatedType in _UpNavigations.Values) { if (EntityAccessControl.GetBuilderForEntity(relatedType).CheckLocalReBuildRequired(clearanceSource)) { _LocalFilterExpression = null; return(true); } } } return(_LocalFilterExpression == null); }
/// <summary> /// returns null when nothing to validate /// </summary> public Expression BuildUntypedFilterExpressionIncludingPrincipals(IClearanceSource clearanceSource, Expression entitySourceExpression = null) { if (entitySourceExpression == null) { //in default we can use the lamba-entry parameter (which is our entity) entitySourceExpression = _EntityParameter; //we get external expressions, when we are called to build expression for just a part of the graph //in this case a member-expression which navigates from ou child up to us is passed via this arg... } Expression result = this.BuildUntypedLocalFilterExpression(clearanceSource, entitySourceExpression); foreach (var nav in _UpNavigations) { String navPropName = nav.Key.Name; Type parentEntityType = nav.Value; MemberExpression targetEntityNavigationExpression = MemberExpression.Property(entitySourceExpression, navPropName); var builderForParentEntityType = EntityAccessControl.GetBuilderForEntity(parentEntityType); Expression targetFilterExpression = builderForParentEntityType.BuildUntypedFilterExpressionIncludingPrincipals(clearanceSource, targetEntityNavigationExpression); //only when the nav has any filtering... if (targetFilterExpression != null) { if (result == null) { result = targetFilterExpression; } else { result = Expression.AndAlso(result, targetFilterExpression); } } } //can be null! return(result); }