Пример #1
0
        private static QuerySourceScope <TEntity> CreateEntity <TEntity>(
            IQuerySource querySource,
            QueryContext queryContext,
            QuerySourceScope parentQuerySourceScope,
            DbDataReader dataReader,
            int readerOffset,
            IEntityType entityType)
        {
            var relationalQueryContext = (RelationalQueryContext)queryContext;

            var valueReader
                = relationalQueryContext.ValueReaderFactory
                  .Create(dataReader);

            if (readerOffset > 0)
            {
                valueReader = new OffsetValueReaderDecorator(valueReader, readerOffset);
            }

            return(new QuerySourceScope <TEntity>(
                       querySource,
                       (TEntity)queryContext.QueryBuffer
                       .GetEntity(entityType, valueReader),
                       parentQuerySourceScope));
        }
Пример #2
0
        private static QuerySourceScope <TEntity> CreateEntity <TEntity>(
            IQuerySource querySource,
            QueryContext queryContext,
            QuerySourceScope parentQuerySourceScope,
            DbDataReader dataReader,
            int readerOffset)
        {
            var relationalQueryContext = (RelationalQueryContext)queryContext;

            var valueReader
                = relationalQueryContext.ValueReaderFactory.Create(dataReader);

            if (readerOffset > 0)
            {
                valueReader = new OffsetValueReaderDecorator(valueReader, readerOffset);
            }

            return(new QuerySourceScope <TEntity>(
                       querySource,
                       // ReSharper disable once AssignNullToNotNullAttribute
                       (TEntity)queryContext.StateManager
                       .GetOrMaterializeEntry(
                           queryContext.Model.GetEntityType(typeof(TEntity)),
                           valueReader).Entity,
                       parentQuerySourceScope));
        }
        private static QuerySourceScope <TEntity> CreateEntity <TEntity>(
            IQuerySource querySource,
            QueryContext queryContext,
            QuerySourceScope parentQuerySourceScope,
            DbDataReader dataReader,
            int readerOffset,
            IEntityType entityType,
            bool queryStateManager,
            EntityKeyFactory entityKeyFactory,
            IReadOnlyList <IProperty> keyProperties,
            Func <IValueReader, object> materializer)
            where TEntity : class
        {
            var valueReader
                = ((RelationalQueryContext)queryContext).ValueReaderFactory
                  .Create(dataReader);

            if (readerOffset > 0)
            {
                valueReader = new OffsetValueReaderDecorator(valueReader, readerOffset);
            }

            var entityKey
                = entityKeyFactory.Create(entityType, keyProperties, valueReader);

            return(new QuerySourceScope <TEntity>(
                       querySource,
                       (TEntity)queryContext.QueryBuffer
                       .GetEntity(
                           entityType,
                           entityKey,
                           new EntityLoadInfo(
                               valueReader,
                               materializer),
                           queryStateManager),
                       parentQuerySourceScope));
        }