/// <summary> /// Executes a query that selects only the desired fields from an <see cref="IQueryable{TItem}"/>. /// </summary> public async Task <QueriedDataIterator> SelectFieldsOnlyAsync(IQueryable <TItem> items, ForEachAsyncDelegate <object> forEachAsync) { Type dynamicType = GetDynamicRuntimeType(); IQueryable dynamicQueryable = GetDynamicQueryable(items, dynamicType); var replacementProcessor = new FieldReplacementProcessor <TItem>(_fieldReaders); await replacementProcessor.LoadAllAsync(items); List <object> dynamicObjects = await ExecuteWithReplacementsAsync(replacementProcessor, dynamicQueryable, forEachAsync); return(new QueriedDataIterator(dynamicObjects)); }
public async Task <RestItemData> SelectFieldsOnlyAsync(TItem item) { Type dynamicType = GetDynamicRuntimeType(); object dynamicObj = GetDynamicObject(item, dynamicType); if (dynamicObj == null) { return(null); } IQueryable <TItem> items = new[] { item }.AsQueryable(); var replacementProcessor = new FieldReplacementProcessor <TItem>(_fieldReaders); await replacementProcessor.LoadAllAsync(items); replacementProcessor.Replace(dynamicObj, dynamicType); return(new RestItemData(dynamicObj)); }