public static void SetSingleQueryFilter(this IMutableEntityType entityData, SingleQueryFilterTypes queryFilterType, IUserId userIdProvider = null) { var methodName = $"Get{queryFilterType}Filter"; var methodToCall = typeof(SingleQueryFilterExtensions) .GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Static) .MakeGenericMethod(entityData.ClrType); var filter = methodToCall .Invoke(null, new object[] { userIdProvider }); entityData.SetQueryFilter((LambdaExpression)filter); }
public static void SetSingleQueryFilter(this IMutableEntityType entityData, SingleQueryFilterTypes queryFilterType, IUserId userIdProvider = null) { var methodName = $"Get{queryFilterType}Filter"; var methodToCall = typeof(SingleQueryFilterExtensions) .GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Static) .MakeGenericMethod(entityData.ClrType); var filter = methodToCall .Invoke(null, new object[] { userIdProvider }); entityData.SetQueryFilter((LambdaExpression)filter); if (queryFilterType == SingleQueryFilterTypes.SingleSoftDelete || queryFilterType == SingleQueryFilterTypes.SingleSoftDeleteDdd) { entityData.AddIndex(entityData.FindProperty(nameof(ISingleSoftDelete.SoftDeleted))); } if (queryFilterType == SingleQueryFilterTypes.SingleSoftDeleteAndUserId) { entityData.AddIndex(entityData.FindProperty(nameof(IUserId.UserId))); } }