private Action <TInclude> GetJoinDictionaryCallback(PropertyInfo property, IncludeResultOperator @operator, ICompiledQuery <TDoc, TOut> query)
        {
            var queryProperty = GetPropertyInfo(property, @operator);

            var storage = _storage.StorageFor(typeof(TInclude));

            var dictionary = (IDictionary <TKey, TInclude>)(queryProperty).GetValue(query);

            if (dictionary == null)
            {
                queryProperty.SetValue(query, new Dictionary <TKey, TInclude>());
                dictionary = (IDictionary <TKey, TInclude>)queryProperty.GetValue(query);
            }

            return(x => {
                var id = storage.Identity(x).As <TKey>();
                if (!dictionary.ContainsKey(id))
                {
                    dictionary.Add(id, x);
                }
            });
        }
Esempio n. 2
0
 public ISelector <TSearched> WrapSelector <TSearched>(StorageFeatures storage, ISelector <TSearched> inner)
 {
     return(new IncludeSelector <TSearched, T>(TableAlias, _mapping, _callback, inner, storage.StorageFor(typeof(T)).As <IDocumentStorage <T> >()));
 }