internal override IList GetIListSourceListInternal()
 {
     if (this._cachedBindingList == null)
     {
         this.EnsureCanEnumerateResults();
         this._cachedBindingList = ObjectViewFactory.CreateViewForQuery <T>(this._resultItemType, (IEnumerable <T>) this, this._shaper.Context, this._shaper.MergeOption == MergeOption.NoTracking, this._singleEntitySet);
     }
     return((IList)this._cachedBindingList);
 }
Example #2
0
        internal override IList GetIListSourceListInternal()
        {
            // You can only enumerate the query results once, and the creation of an ObjectView consumes this enumeration.
            // However, there are situations where setting the DataSource of a control can result in multiple calls to this method.
            // In order to enable this scenario and allow direct binding to the ObjectResult instance,
            // the ObjectView is cached and returned on subsequent calls to this method.

            if (_cachedBindingList == null)
            {
                EnsureCanEnumerateResults();

                var forceReadOnly = _shaper.MergeOption == MergeOption.NoTracking;
                _cachedBindingList = ObjectViewFactory.CreateViewForQuery(
                    _resultItemType, this, _shaper.Context, forceReadOnly, _singleEntitySet);
            }

            return(_cachedBindingList);
        }