Reputation: 67
internal static IQueryable<TimeReviewDataModel> GetGridDetails(DiscoLlamaEntities context, string actor)
{
return (from t in context.TimeCaptures
join jc in context.JobCards on t.JobCardID equals jc.ID into jcSub
from jc in jcSub.DefaultIfEmpty()
join cu in context.Companies on jc.CustomerID equals cu.ID into cuSub
from tg in cuSub.DefaultIfEmpty()
where (t.CreatedBy == actor)
orderby t.Date descending
select new TimeReviewDataModel
{
ID = t.ID,
CustomerName = tg.Name,
Date = t.Date,
StartTime = t.StartTime,
EndTime = t.EndTime,
Description = t.Description,
Category = t.Category,
JobCardID = t.JobCardID,
VsoTask = t.VsoTaskID,
IsBillable = (bool)t.Billable
})
.OrderBy(e=>e.Date);
}
Hi, I'm trying to order my data in a grid. At the top I want the data that was entered today as the grid goes down I want the previously added entries. Currently it mixes the entries. I want to order using the Date property.
I'm using Linq and EntityFramework.
My Grid:
Upvotes: 2
Views: 60
Reputation: 5550
Try the following:
return (from t in context.TimeCaptures
join jc in context.JobCards on t.JobCardID equals jc.ID into jcSub
from jc in jcSub.DefaultIfEmpty()
join cu in context.Companies on jc.CustomerID equals cu.ID into cuSub
from tg in cuSub.DefaultIfEmpty()
where (t.CreatedBy == actor)
//orderby t.Date descending
select new TimeReviewDataModel
{
ID = t.ID,
CustomerName = tg.Name,
Date = t.Date,
StartTime = t.StartTime,
EndTime = t.EndTime,
Description = t.Description,
Category = t.Category,
JobCardID = t.JobCardID,
VsoTask = t.VsoTaskID,
IsBillable = (bool)t.Billable
})
.OrderByDescending(e=>e.Date).ThenByDescending(e=>eStartTime);
So, here you are ordering your final dataset, not an intermediate one.
Upvotes: 1