Exemple #1
0
        /// <summary>Gets the enumerator.</summary>
        /// <returns>The enumerator.</returns>
        public IEnumerator <T> GetEnumerator()
        {
            var enumerators = OriginalQueryable.GetEnumerator();



            var      asNoTracking = OriginalQueryable.Expression.ToString().Contains("MergeAs(NoTracking)");
            List <T> list         = new List <T>();

            while (enumerators.MoveNext())
            {
                list.Add(enumerators.Current);
            }
            // todo: add all current objects
            List <object> includedObjects = new List <object>();
            List <object> excludedObjects = new List <object>();

            foreach (var includeFilter in IncludeFilters)
            {
                includeFilter.ApplyFilter(list.Cast <object>().ToList());

                includedObjects.AddRange(includeFilter.GetIncludedList());
                excludedObjects.AddRange(includeFilter.GetExcludedList());
            }

            includedObjects.AddRange(list.Cast <object>());

            excludedObjects = excludedObjects.Except(includedObjects).ToList();

            var context = OriginalQueryable.GetObjectQuery().Context;

            excludedObjects.ForEach(x => context.DeleteObject(x));

            return(list.GetEnumerator());
        }
Exemple #2
0
 /// <summary>Gets the enumerator.</summary>
 /// <returns>The enumerator.</returns>
 IEnumerator IEnumerable.GetEnumerator()
 {
     return(OriginalQueryable.GetEnumerator());
 }