Get acces from presentation layer to repository models

Apr 24, 2016 at 6:39 PM
Hi, awesome framework!!

I try to make a controller on MVC to receive an IEnumerable<CustomerOrder> from service layer, and service layer takeit from repository layer, but MVC don't recognize CustomerOder

repository
    public static IEnumerable<CustomerOrder> GetCustomerOrder(
        this IRepository<Customer> repository, 
        string country)
    {
        var customers = repository.GetRepository<Customer>().Queryable();
        var orders = repository.GetRepository<Order>().Queryable();

        var query = from c in customers
            join o in orders on new {a = c.CustomerID, b = c.Country}
                equals new {a = o.CustomerID, b = country}
            select new CustomerOrder
            {
                CustomerId = c.CustomerID,
                ContactName = c.ContactName,
                OrderId = o.OrderID,
                OrderDate = o.OrderDate
            };

        return query.AsEnumerable();
    }
service
  public IEnumerable<CustomerOrder> GetCustomerOrder(string country)
    {
        // add business logic here
        return _repository.GetCustomerOrder(country);
    }
customerOrders.cs
namespace Northwind.Repository.Models
{
    public class CustomerOrder
    {
        public string CustomerId { get; set; }
        public string ContactName { get; set; }
        public int OrderId { get; set; }
        public DateTime? OrderDate { get; set; }
    }
}
MVC
        [HttpGet]
        [Queryable]
        public IQueryable<CustomerOder> GetCustomerOrders()
        {
            return _customerService.GetCustomerOrder("abc");
        }
CustomerOrder.cs is stored in Northwind.Repository and presentation layer don't references
NorthWind.Repository dll.

Must i put CustomerOrder on NorthWind.Entities like storeProcedure Models?

Thanks, this framework is really so usefull to me, really thanks!! :)