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
|
Following code throws: Unable to cast object of type 'Mindscape.LightSpeed.Querying.LogicalExpression' to type 'Mindscape.LightSpeed.Linq.DeferredPathExpression'. What can I do? The code:
db.Context = context; var list =db.Shows .Where(s => s.OpenInternet.Value) .SelectMany(s => db.Performances.Where(p => p.Id == s.Id) .Select(p => new BEPerformance(p.Id, s.Id, s.HallCode.Value, s.ShowDate.Value, false, "http://www.sobaka.co.il/cameri/hall.asp?index=" + p.Id)));return list.ToList(); |
|
|
We have only limited support for SelectMany at the moment so your best bet is to turn the query around a bit: var query = db.Performances This assumes a foreign key relationship between Performances and Shows rather than the identity relationship (p.Id == s.Id) shown in your sample, but I am guessing this must be the case because otherwise each Show could have only one Performance (and you would not be able to sustain the identity relationship because of the way LightSpeed allocates IDs). Also, assuming that the Show.OpenInternet property represents a nullable boolean rather than an association, please note we do not currently handle the Nullable<T>.Value property in where clauses, so you will need to explicitly compare p.Show.OpenInternet.Value to true. I have logged a bug for this behaviour. |
|