Question

IRepositoryBase

IQueryable<T> GetAll(Expression<Func<T, bool>> predicate = null, params Expression<Func<T, object>>[] includes);

RepositoryBase

 public IQueryable<T> GetAll([OptionalAttribute][DefaultParameterValueAttribute(null)]Expression<Func<T, bool>> predicate, params Expression<Func<T, object>>[] includes)     
 {
   var set = CreateSet().IncludeMultiple(includes);
   return (predicate == null) ? set : set.Where(predicate);            
 }

IAccountService

IEnumerable<int> GetAllReferenceIds();

AccountService

public IEnumerable<int> GetAllReferenceIds()       
{    
  var accountOwners = _accountOwnerRepository.GetAll();
  return accountOwners.Select(m => m.ReferenceId).ToList();
}

AccountController

public ActionResult ReferenceIdPartial()      
{

ViewData["AccountOwners"] = accountOwnerService.GetAllReferenceIds();

return PartialView();

}

MVC Partial View - devexpress combobox mvc extension

settings.Properties.Columns.Add("ReferenceId", "Reference Id", Unit.Percentage(100));

Error - column ReferenceId Not found

I am sending a collection of int through GetReferenceIds()

Is there a way to call the columns from Controller. Something like AccountOwner(a=>a.ReferenceIds, select ReferenceIds) - I should be able to get the column name as well as the data.

Thanks for your time.

Was it helpful?

Solution

This is a shot into the dark, I actually only understand your last sentence "I should be able to get the column name as well as the data" - and could imagine that if you bind a collection to a combobox (I don't know the DevExpress combobox extension) the combobox control wants a collection of class objects with a property name/property value pair instead of only a collection of values ( int). So, without touching the AccountService you could try:

public ActionResult ReferenceIdPartial()      
{
    ViewData["AccountOwners"] = accountOwnerService.GetAllReferenceIds()
        .Select(i => new { ReferenceId = i });

    return PartialView();
}

ViewData["AccountOwners"] now would hold a collection of (anonymous) objects. Each object has one property called ReferenceId with a value i fetched from the Ids you returned from your service.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top