private static async Task <Object> CreateNestedEntity(OeDbEnumerator dbEnumerator, Object value, Type nestedEntityType)
        {
            Object entity = dbEnumerator.Current;

            if (entity == null)
            {
                return(null);
            }

            if (dbEnumerator.EntryFactory.ResourceInfo.IsCollection.GetValueOrDefault())
            {
                Type listType = typeof(List <>).MakeGenericType(new[] { nestedEntityType });
                var  list     = (IList)Activator.CreateInstance(listType);

                do
                {
                    Object item = dbEnumerator.Current;
                    if (item != null)
                    {
                        list.Add(await CreateEntity(dbEnumerator, item, item, nestedEntityType).ConfigureAwait(false));
                    }
                }while (await dbEnumerator.MoveNextAsync().ConfigureAwait(false));
                return(list);
            }

            return(await CreateEntity(dbEnumerator, value, entity, nestedEntityType).ConfigureAwait(false));
        }
示例#2
0
 private OeEntityAsyncEnumeratorAdapter(IAsyncEnumerator <Object?> asyncEnumerator, OeEntryFactory entryFactory, OeQueryContext?queryContext)
 {
     _dbEnumerator    = new OeDbEnumerator(asyncEnumerator, entryFactory);
     _queryContext    = queryContext;
     _isFirstMoveNext = true;
     _current         = default;
 }
 public OeEntityAsyncEnumeratorAdapter(OeAsyncEnumerator asyncEnumerator, OeQueryContext queryContext)
     : base(asyncEnumerator.CancellationToken)
 {
     _asyncEnumerator = asyncEnumerator;
     _dbEnumerator    = new OeDbEnumerator(asyncEnumerator, queryContext.EntryFactory);
     _queryContext    = queryContext;
     _isFirstMoveNext = true;
 }
示例#4
0
 private OeEntityAsyncEnumeratorAdapter(OeAsyncEnumerator asyncEnumerator, OeEntryFactory entryFactory, OeQueryContext queryContext)
     : base(asyncEnumerator.CancellationToken)
 {
     _asyncEnumerator = asyncEnumerator;
     _dbEnumerator    = new OeDbEnumerator(asyncEnumerator, entryFactory);
     _queryContext    = queryContext;
     _isFirstMoveNext = true;
     base.Count       = asyncEnumerator.Count;
 }
示例#5
0
        private OeDbEnumerator(OeDbEnumerator parentEnumerator, OeEntryFactory entryFactory)
        {
            ParentEnumerator = parentEnumerator;
            Context          = parentEnumerator.Context;
            EntryFactory     = entryFactory;

            if (entryFactory.EdmNavigationProperty.Type.Definition is EdmCollectionType)
            {
                _uniqueConstraint = new HashSet <Object>(entryFactory.EqualityComparer);
            }

            Initialize();
        }
示例#6
0
 public OeDbEnumerator GetFromPool(OeDbEnumerator parentEnumerator, OeEntryFactory entryFactory)
 {
     if (_pool.TryGetValue(entryFactory, out OeDbEnumerator dbEnumerator))
     {
         dbEnumerator.Initialize();
     }
     else
     {
         dbEnumerator = new OeDbEnumerator(parentEnumerator, entryFactory);
         _pool.Add(entryFactory, dbEnumerator);
     }
     return(dbEnumerator);
 }
示例#7
0
        private OeDbEnumerator(OeDbEnumerator parentEnumerator, OeEntryFactory entryFactory)
        {
            ParentEnumerator = parentEnumerator;
            Context          = parentEnumerator.Context;
            EntryFactory     = entryFactory;

            if (entryFactory.ResourceInfo.IsCollection.GetValueOrDefault())
            {
                _uniqueConstraint = new HashSet <Object>(entryFactory.EqualityComparer);
            }

            Initialize();
        }
        private static async Task SetNavigationProperty(OeDbEnumerator dbEnumerator, Object value, Object entity)
        {
            PropertyInfo propertyInfo     = entity.GetType().GetProperty(dbEnumerator.EntryFactory.ResourceInfo.Name);
            Type         nestedEntityType = OeExpressionHelper.GetCollectionItemType(propertyInfo.PropertyType);

            if (nestedEntityType == null)
            {
                nestedEntityType = propertyInfo.PropertyType;
            }

            Object navigationValue = await CreateNestedEntity(dbEnumerator, value, nestedEntityType).ConfigureAwait(false);

            propertyInfo.SetValue(entity, navigationValue);
        }
        private static async Task <Object> CreateEntity(OeDbEnumerator dbEnumerator, Object value, Object entity, Type entityType)
        {
            if (OeExpressionHelper.IsTupleType(entity.GetType()))
            {
                value  = entity;
                entity = CreateEntityFromTuple(entityType, entity, dbEnumerator.EntryFactory.Accessors);
            }

            foreach (OeEntryFactory navigationLink in dbEnumerator.EntryFactory.NavigationLinks)
            {
                await SetNavigationProperty(dbEnumerator.CreateChild(navigationLink), value, entity).ConfigureAwait(false);
            }

            return(entity);
        }