private dynamic CreateOrders(int i)
 {
     EdmEntityObject[] orders = new EdmEntityObject[i];
     for (int j = 0; j < i; j++)
     {
         dynamic order = new EdmEntityObject(OrderType);
         order.Id = j;
         order.ShippingAddress = CreateAddress(j);
         orders[j] = order;
     }
     var collection = new EdmEntityObjectCollection(new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(OrderType, false)), false), orders);
     return collection;
 }
 private dynamic CreateOrder(int j)
 {
     dynamic order = new EdmEntityObject(OrderType);
     order.Id = j;
     order.ShippingAddress = CreateAddress(j);
     return order;
 }
        public IHttpActionResult Get()
        {
            IEdmEntityObject[] untypedCustomers = new EdmEntityObject[20];
            for (int i = 0; i < 20; i++)
            {
                dynamic untypedCustomer = new EdmEntityObject(CustomerType);
                untypedCustomer.Id = i;
                untypedCustomer.Name = string.Format("Name {0}", i);
                untypedCustomer.Orders = CreateOrders(i);
                untypedCustomer.Addresses = CreateAddresses(i);
                untypedCustomer.FavoriteNumbers = Enumerable.Range(0, i).ToArray();
                untypedCustomers[i] = untypedCustomer;
            }

            IEdmCollectionTypeReference entityCollectionType =
                new EdmCollectionTypeReference(
                    new EdmCollectionType(new EdmEntityTypeReference(CustomerType, isNullable: false)),
                    isNullable: false);

            return Ok(new EdmEntityObjectCollection(entityCollectionType, untypedCustomers.ToList()));
        }