//------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // // WillA //------------------------------------------------------------------------------ using System; using System.Collections.Generic; using System.Data.Common; using System.Data.Common.Utils; using System.Data.EntityClient; using System.Data.Common.Internal.Materialization; using System.Data.Metadata.Edm; using System.Linq; using System.Text; namespace System.Data.Objects { internal class NextResultGenerator { EntityCommand _entityCommand; ReadOnlyMetadataCollection _entitySets; ObjectContext _context; EdmType[] _edmTypes; int _resultSetIndex; MergeOption _mergeOption; internal NextResultGenerator(ObjectContext context, EntityCommand entityCommand, EdmType[] edmTypes, ReadOnlyMetadataCollection entitySets, MergeOption mergeOption, int resultSetIndex) { _context = context; _entityCommand = entityCommand; _entitySets = entitySets; _edmTypes = edmTypes; _resultSetIndex = resultSetIndex; _mergeOption = mergeOption; } internal ObjectResult GetNextResult(DbDataReader storeReader) { bool isNextResult = false; try { isNextResult = storeReader.NextResult(); } catch (Exception e) { if (EntityUtil.IsCatchableExceptionType(e)) { throw EntityUtil.CommandExecution(System.Data.Entity.Strings.EntityClient_StoreReaderFailed, e); } throw; } if (isNextResult) { EdmType edmType = _edmTypes[_resultSetIndex]; MetadataHelper.CheckFunctionImportReturnType(edmType, _context.MetadataWorkspace); return _context.MaterializedDataRecord(_entityCommand, storeReader, _resultSetIndex, _entitySets, _edmTypes, _mergeOption); } else { return null; } } } }