コード例 #1
0
        /// <summary>
        ///     Globally disable the filter.  Can be enabled as needed via DbContext.EnableFilter().
        /// </summary>
        /// <param name="modelBuilder"></param>
        /// <param name="filterName"></param>
        public static void DisableFilterGlobally(this DbModelBuilder modelBuilder, string filterName)
        {
            filterName = ScrubFilterName(filterName);

            GlobalParameterValues.AddOrUpdate(filterName,
                                              f =>
            {
                var newValues     = new DynamicFilterParameters();
                newValues.Enabled = false;
                return(newValues);
            },
                                              (f, currValues) =>
            {
                currValues.Enabled = false;
                return(currValues);
            });
        }
コード例 #2
0
        public static void SetFilterGlobalParameterValue(this DbContext context, string filterName, string parameterName,
                                                         object value)
        {
            filterName = ScrubFilterName(filterName);

            if (string.IsNullOrEmpty(parameterName))
            {
                parameterName = GetDefaultParameterNameForFilter(filterName);
            }

            GlobalParameterValues.AddOrUpdate(filterName,
                                              f =>
            {
                var newValues = new DynamicFilterParameters();
                newValues.SetParameter(parameterName, value);
                return(newValues);
            },
                                              (f, currValues) =>
            {
                currValues.SetParameter(parameterName, value);
                return(currValues);
            });
        }