Select only the columns I want?

Feb 20, 2014 at 12:47 AM
In your example you have this:

var customers =
        unitOfWork.Repository<Customer>()
            .Query()
            .Include(i => i.CustomerDemographics)
            .OrderBy(q => q
                .OrderBy(c => c.ContactName)
                .ThenBy(c => c.CompanyName))
            .Filter(q => q.ContactName != null)
            .GetPage(pageNumber, pageSize, out totalCustomerCount);
Is there a way to select the columns you want returned instead of all of them? I need a .Select for the columns.

var customers =
        unitOfWork.Repository<Customer>()
            .Query()                
            .Filter(q => q.ContactName != null)
            .Select(
                  s =>
                      new
                          {
                               s.CustomerID,
                               s.FirstName + " " + s.LastName
                           }
                      )
             .Take(10)
             .ToArray();
I am assuming the GetPage handles the .Take(10)?

I need something like this because I am using an auto complete controller for jQuery auto complete and I only need to return the ID and the name concated together.
Coordinator
Apr 1, 2014 at 5:38 AM
There is a Select overload that will let you do projections released.
Marked as answer by lelong37 on 3/31/2014 at 10:38 PM