예제 #1
0
        /// <summary>
        /// Called after a update database command execute
        /// </summary>
        /// <typeparam name="T">Data type</typeparam>
        /// <param name="updateByQueryContext">Update by query context</param>
        public virtual void OnUpdateByQueryCallback <T>(UpdateByQueryContext <T> updateByQueryContext) where T : BaseEntity <T>, new()
        {
            if (updateByQueryContext?.GetDatasProxy == null)
            {
                return;
            }
            var datas = updateByQueryContext.GetDatasProxy(updateByQueryContext.Query);

            AddCacheData(new QueryDataCallbackContext <T>()
            {
                Datas = datas,
                Query = updateByQueryContext.Query
            });
        }
예제 #2
0
        /// <summary>
        /// Called before a update database command execute
        /// </summary>
        /// <typeparam name="T">Data type</typeparam>
        /// <param name="updateByQueryContext">Update by query context</param>
        /// <returns>Return policy result</returns>
        public virtual StartingResult OnUpdateByQueryStarting <T>(UpdateByQueryContext <T> updateByQueryContext) where T : BaseEntity <T>, new()
        {
            if (updateByQueryContext == null)
            {
                return(StartingResult.Success($"Parameter:{nameof(updateByQueryContext)} is null"));
            }
            if (updateByQueryContext.GetDatasProxy == null)
            {
                return(StartingResult.Success($"Parameter:{nameof(UpdateByQueryContext<T>.GetDatasProxy)} is null"));
            }
            var datas = updateByQueryContext.GetDatasProxy(updateByQueryContext.Query);

            try
            {
                RemoveCacheData(datas);
            }
            catch (Exception ex)
            {
                return(DataCacheBehavior.GetStartingResult(DataCacheOperation.RemoveData, ex));
            }
            return(StartingResult.Success());
        }