Esempio n. 1
0
        public void Bind_GeneratedExpression_ContainsExpandedObject()
        {
            // Arrange
            SelectExpandQueryOption selectExpand = new SelectExpandQueryOption("Orders,Orders/Customer", "Orders,Orders/Customer", _context);

            // Act
            IQueryable queryable = SelectExpandBinder.Bind(_queryable, _settings, selectExpand);

            // Assert
            IEnumerator enumerator = queryable.GetEnumerator();

            Assert.True(enumerator.MoveNext());
            var partialCustomer = Assert.IsType <SelectExpandWrapper <Customer> >(enumerator.Current);

            Assert.False(enumerator.MoveNext());
            Assert.Null(partialCustomer.Instance);
            IEnumerable <SelectExpandWrapper <Order> > innerOrders = partialCustomer.Container.ToDictionary()["Orders"] as IEnumerable <SelectExpandWrapper <Order> >;

            Assert.NotNull(innerOrders);
            SelectExpandWrapper <Order> partialOrder = innerOrders.Single();

            Assert.Same(_queryable.First().Orders.First(), partialOrder.Instance);
            SelectExpandWrapper <Customer> innerInnerCustomer = Assert.IsType <SelectExpandWrapper <Customer> >(partialOrder.Container.ToDictionary()["Customer"]);

            Assert.Same(_queryable.First(), innerInnerCustomer.Instance);
        }
        public static object Bind(object entity, ODataQuerySettings settings, SelectExpandQueryOption selectExpandQuery)
        {
            Contract.Assert(entity != null);

            SelectExpandBinder binder = new SelectExpandBinder(settings, selectExpandQuery);
            return binder.Bind(entity);
        }
        public static IQueryable Bind(IQueryable queryable, ODataQuerySettings settings, SelectExpandQueryOption selectExpandQuery)
        {
            Contract.Assert(queryable != null);

            SelectExpandBinder binder = new SelectExpandBinder(settings, selectExpandQuery);
            return binder.Bind(queryable);
        }
Esempio n. 4
0
        public static object Bind(object entity, ODataQuerySettings settings, SelectExpandQueryOption selectExpandQuery)
        {
            Contract.Assert(entity != null);

            SelectExpandBinder binder = new SelectExpandBinder(settings, selectExpandQuery);

            return(binder.Bind(entity));
        }
Esempio n. 5
0
        public static IQueryable Bind(IQueryable queryable, ODataQuerySettings settings, SelectExpandQueryOption selectExpandQuery)
        {
            Contract.Assert(queryable != null);

            SelectExpandBinder binder = new SelectExpandBinder(settings, selectExpandQuery);

            return(binder.Bind(queryable));
        }
Esempio n. 6
0
        public void Bind_ReturnsIEdmObject_WithRightEdmType()
        {
            // Arrange
            SelectExpandQueryOption selectExpand = new SelectExpandQueryOption(select: "ID", expand: null, context: _context);

            // Act
            IQueryable queryable = SelectExpandBinder.Bind(_queryable, _settings, selectExpand);

            // Assert
            Assert.NotNull(queryable);
            IEdmTypeReference edmType = _model.Model.GetEdmTypeReference(queryable.GetType());

            Assert.NotNull(edmType);
            Assert.True(edmType.IsCollection());
            Assert.Same(_model.Customer, edmType.AsCollection().ElementType().Definition);
        }