示例#1
0
        protected override IEnumerable <string> GetIdentifiersToRequest()
        {
            if (!_expressionInfo.FilterInfo.IdentifiersRangeFound)
            {
                return(null);
            }

            return(_expressionInfo.FilterInfo.Identifiers.Except(_savable.GetAllPendingChangesIdentifiers()));
        }
        protected override IEnumerable GetEntities(IEnumerable <string> identifiers)
        {
            var identifiersToRequest = identifiers.Except(_savable.GetAllPendingChangesIdentifiers());

            var entities = GetEntitiesFromCache(identifiers);

            return(_savable.CombineWithPendingChanges(entities, _predicate));
        }
        protected override IEnumerable GetEntities(IEnumerable <string> identifiers)
        {
            var identifiersToRequest = identifiers.Except(_savable.GetAllPendingChangesIdentifiers());

            if (_expressionInfo.InnerMostExpression.Method.Name == nameof(Queryable.FirstOrDefault) ||
                _expressionInfo.InnerMostExpression.Method.Name == nameof(Queryable.LastOrDefault))
            // other methods like that
            {
                // do not care about order, so FirstOrDefault and LastOrDefault are the same
                identifiersToRequest = identifiersToRequest.Take(1);
            }
            var entities = identifiersToRequest.Any() ? GetEntitiesFromDao(identifiersToRequest) : Enumerable.Empty <T>();

            return(_savable.CombineWithPendingChanges(entities, _predicate));
        }
示例#4
0
        protected override IEnumerable GetEntities(IEnumerable <string> identifiers)
        {
            var method = _expressionInfo.InnerMostExpression.Method;

            if (!IsNonReplacableMethod(method))
            {
                return(_savable.CombineIdentifiersRangeWithPendingChanges(identifiers, _predicate));
            }

            // non - replacable methods, we need entities
            var identifiersToRequest = identifiers.Except(_savable.GetAllPendingChangesIdentifiers());
            // assume we can just get if from the cache directly for no other properties except key are used.
            var entities = identifiersToRequest.Any() ? _cachedDataProvider.GetCachedEntities(identifiersToRequest) : Enumerable.Empty <T>();

            //var entities = identifiersToRequest.Any() ? _cachedDataProvider.GetEntitiesBasedOnCache(identifiersToRequest) : Enumerable.Empty<T>();

            return(_savable.CombineWithPendingChanges(entities, _predicate));
        }