linq to sql select as command linq to sql select as command database database

linq to sql select as command


From your previous question, I guess you have a query like, below. You can use select new to create an anonymous type object and then use OrderBy like:

var query = (from activeWO in context.ActiveWOs            join activeWOUpdated in context.ActiveWOUpdatedTimes on activeWO.PW_ID equals activeWOUpdated.PW_ID into dj            from activeWOUpdated in dj.DefaultIfEmpty()            where activeWO.WODC.Contains("IDC")            select new             {              TimeLeft = activeWO.StartTime * 60 * 60 * 24 - dj.ElapsedTime            }).Orderby(r=> r.TimeLeft); 


Use anonymous types:

var results = ... //your query              .Select(a => new                {                  TimeLeft = a.StartTime * 60 * 60 * 24 - a.ElapsedTime               });