Say I have a query that selects into a defined type like so:
public class SomeObject
{
public DateTime CreatedDate { get; set; }
}
private class MyType
{
internal SomeObject Object1 { get; set; }
internal SomeThing Object2 { get; set; }
internal DateTime SomeDate { get; set; }
}
var query = from bla in context.Melp join .....
select new MyType()
{
Object1 = something,
Object2 = somethingelse,
SomeDate = bla.date
}
Now we DynamicLinq to add dynamic, user defined, sort on the result set, like so:
query.OrderBy("SomeDate");
or
query.OrderBy("Object1.CreatedDate");
but when I try to order on, for example, "SomeDate" or "Object1.CreatedDate", I get prompted with an exception:
No property or field 'SomeDate' exists in type 'MyType'
Now, when I just add the ordering in method syntax to the query:
query = query.OrderBy(x => x.SomeDate)
or
query = query.OrderBy(x => x.Object1.CreatedDate)
Everything works, so I think this might be either a bug in DynamicLinq or I'm calling it wrong...
Any ideas?