I'm using linq in nhibernate and I have problem when I try to use OrderBy using Dynamic Linq:
var bugAndFeatures = (from u in session.Query<BugAndFeature>()
let uEmployeeFullName = string.Format("{0} {1}", u.Employee.Surname, u.Employee.FirstName)
where u.IsDelete == false
select new BugAndFeatureView()
{
Id = u.Id,
Title = u.Title,
Description = u.Description,
EmployeeFullName = uEmployeeFullName,
EmployeeLogin = u.Employee.User.Login,
AssignedEmployeeId = u.AssignedEmployee == null ? 0 : u.AssignedEmployee.Id,
AssignedEmployeeFullName = string.Format("{0} {1}", u.AssignedEmployee.Surname, u.AssignedEmployee.FirstName),
CreateDate = u.CreateDate.Equals(null) ? string.Empty : u.CreateDate.ToString(),
LastUpdateDate = u.LastUpdateDate.Equals(null) ? string.Empty : u.LastUpdateDate.ToString()
}
);
After that I would like to use dynamic linq and use OrderBy like OrderBy("EmployeeFullName DESC") and I couldn't do that because I have exception. I noticed that when I'm doing OrderBy on any property which I don't format or check null etc. I don't have this problem it only occurs when I try to do orderby with formated properties. If I do ToList() before OrderBy then I don't have this problem but I don't want to do that I need use IQueryable.
How can I modify this query to solve my issue?
Thanks for help.