all…
I’m using RavenDB embedded, latest stable build using NuGet and MVC 3.
public JsonResult GetStudents(GridFilter filter)
{
using (var session = _store.OpenSession())
{
var students = session.Query<Student>();
students.OrderBy(x => x.FirstName);
return Json(students.ToList());
}
}
This code doesn’t break. It also doesn’t sort on Student.FirstName. I looked at the RavenQueryInspector (mousing over the students collection) and found the following…
AsyncDatabaseCommands = '(((Raven.Client.Linq.RavenQueryInspector<UMA.KendoGrid.Entities.Student>)(students))).AsyncDatabaseCommands' threw an exception of type 'System.NotSupportedException'
If I do
var students = from x in session.Query<Student>()
orderby x.FirstName descending
select x;
that works fine. First, I don’t understand why using lambda fails when using the long linq syntax works. What I REALLY need is to filter students by any field, as I’m using a grid with sort ability. I would like to use the System.Linq.Dynamic file from Microsoft to sort by string name, that way I can sort by whatever fields are passed in my sort collection.
But, to get started, I think I need to figure out why my version of RavenDB embedded won’t allow me to use lambda expressions. Can anyone help?
On this statement:
… you’re ignoring the result of the call. It’s the LINQ equivalent of the “ignoring the result of a string call” bug:
LINQ calls never change what they’re called on – they return a new collection with the appropriate transformation. So you want:
Or, better: