Ejemplo n.º 1
0
        /// <summary>
        /// Save a query model result for later lookup.
        /// </summary>
        /// <param name="queryModel"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        /// <remarks>Cache any QueryReferences that have been looked up in addtion to the result so we know when to
        /// invalidate this.</remarks>
        public IVariableScopeHolder Add(Remotion.Linq.QueryModel queryModel, Expression result)
        {
            var scope = new CQReplacementExpression(this, queryModel, _queryModelCache.ContainsKey(queryModel) ? _queryModelCache[queryModel] : null);
            var v     = new QueryModelCacheLine()
            {
                _value = result, _referencedQS = _QSReferencedSet.ToArray()
            };

            _QSReferencedSet.Clear();
            AddInternal(queryModel, v);
            return(scope);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get back a query replacement. Null we can't find it.
        /// </summary>
        /// <param name="queryModel"></param>
        /// <returns></returns>
        public Expression GetReplacement(QueryModel queryModel)
        {
            QueryModelCacheLine result = null;

            if (_queryModelCache.TryGetValue(queryModel, out result))
            {
                Debug.WriteLine("Cache Lookup QM Would have returned {0} => {1}", queryModel.ToString(), result.ToString());
                Debug.Indent();
                foreach (var qs in _queryReplacement)
                {
                    Debug.WriteLine("QS {0} => {1}", qs.Key, qs.Value);
                }
                Debug.Unindent();
                return(result._value);
            }
            return(null);
        }
Ejemplo n.º 3
0
 private void AddInternal(Remotion.Linq.QueryModel queryModel, QueryModelCacheLine v)
 {
     _queryModelCache[queryModel] = v;
     Debug.WriteLine("Caching: QM {0} => {1}", queryModel.ToString(), v._value.ToString());
 }
Ejemplo n.º 4
0
 public CQReplacementExpression(CodeContext context, QueryModel model, QueryModelCacheLine val)
 {
     _context = context;
     _model   = model;
     _oldVal  = val;
 }
Ejemplo n.º 5
0
 public CQReplacementExpression(CodeContext context, QueryModel model, QueryModelCacheLine val)
 {
     _context = context;
     _model = model;
     _oldVal = val;
 }
Ejemplo n.º 6
0
 private void AddInternal(Remotion.Linq.QueryModel queryModel, QueryModelCacheLine v)
 {
     _queryModelCache[queryModel] = v;
     Debug.WriteLine("Caching: QM {0} => {1}", queryModel.ToString(), v._value.ToString());
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Save a query model result for later lookup.
 /// </summary>
 /// <param name="queryModel"></param>
 /// <param name="result"></param>
 /// <returns></returns>
 /// <remarks>Cache any QueryReferences that have been looked up in addtion to the result so we know when to
 /// invalidate this.</remarks>
 public IVariableScopeHolder Add(Remotion.Linq.QueryModel queryModel, Expression result)
 {
     var scope = new CQReplacementExpression(this, queryModel, _queryModelCache.ContainsKey(queryModel) ? _queryModelCache[queryModel] : null);
     var v = new QueryModelCacheLine() { _value = result, _referencedQS = _QSReferencedSet.ToArray() };
     _QSReferencedSet.Clear();
     AddInternal(queryModel, v);
     return scope;
 }