This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have a Job object who has a one to many relationship to a Session object. These Session objects have a start time and an end time. 1st Problem I would like to search for jobs who have sessions start time at a particular date(not time) and a Job name that contains particular string. Ive tried: var jobs = uow.Jobs.Where(j => j.Name.Contains(str)).Where(j => j.Sessions.Min(s => s.Start) >= somedate && j.Sessions.Min(s => s.End) <= someotherdate)
2nd Problem Also I'd like to create an anonymous type from the foudn list like so: var res = from j in jobs select new{ name = j.Name, startDate = j.Sessions.Min(s => s.Start), status = 0 }; This gives me a MySQL error that column Start coudl not be found. WHen I comment out the line with the Min aggregate I get an exception because of the status = 0 line. Is this a bug or am I not "getting" how LINQ should work?
|
|
|
We have a limitation at the moment in our LINQ provider that we support aggregate operators like Min, Max, Sum, Any, etc. only on queries as a whole (effectively applying to the results of the query), not as part of the query expression -- either in a Where clause, as in your first example, or in a Select clause, as in your second example. We plan to remove this limitation in a future version (and we recognise that in the meantime we need to document it more clearly). The exception with the status = 0 line is a bug and I am investigating a fix. |
|
|
The issue with using constants / literals in projections is now fixed and the fix will be in future nightly builds. Thanks for letting us know about this. |
|