I'm using a repository for my models like this
public IEnumerable<object> GetDetailList(int userId, int page, int rp, string sortname, string sortorder, ref int num, ref int numpg)
{
var details = (from access in context.erp_sec_companyaccesses
join company in context.erp_maint_companies on Convert.ToInt32(access.company_id) equals company.company_id
where access.user_id == userId
select new
{
pkey = access.company_access_id,
company_access_id = access.company_access_id,
company_code = company.company_code,
company_name = company.company_name,
company_id = company.company_id
});
num = details.Count();
numpg = (int)Math.Ceiling((float)(num / rp));
details = details.OrderBy(sortname+" "+sortorder).Skip(page * rp).Take(rp);
return details;
}
But I'm struggling to upcast the IEnumerable<object>
returned to the controller. Is there any alternative than this ?
Update : I give up up-casting, I'll send a typed object instead of anonymous, thanks everybody