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
|
Hi all,
here is the code that generates the following problem:
"This expression type is not supported in LightSpeed 3.0" It's an expression that groups some data, then joins other data on two keys, then does some more joining and finally selects a desired dataset..no errors in compile time... Any ideas ?
using (AEKUnitOfWork uow = RepositoryAEK.Context.CreateUnitOfWork()){
var list = uow.Kontaktstatuses.GroupBy(contactStatus => contactStatus.IdkontaktId).Select(contactStatus => new{contactId = contactStatus.Key,lastEntry = contactStatus.Max(contactStatusEntry => contactStatusEntry.Vrijeme)}).Join(uow.Kontaktstatuses, outer => new{id = outer.contactId,time = outer.lastEntry}, inner => new{id = inner.IdkontaktId,time= inner.Vrijeme}, (status_1, status_2) =>new{contactId = status_2.IdkontaktId}).Join(uow.Kontaktis, outer => outer.contactId, inner => inner.Id,(inner, outer) => new{contactId= inner.contactId,responsibilityId=outer.IdnadleznostId,desciption=outer.Opis.Trim(),createDate = outer.Vrijemeupisa}).Join(uow.Nadleznosts, outer => outer.responsibilityId, inner => inner.Id,(inner, outer) => new{contactId = inner.contactId,desciption=inner.desciption,createDate = inner.createDate,rmsNotification=outer.Rmsnotifikator,forwardToOrganizationalUnit=outer.Idorgjeddefaultproslijedi,inform=outer.Informiranje});
}
|
|
|
The aspect of the query that is not supported is that you are trying to perform a server side join against a sub-query which contains a grouping statement. Currently in LightSpeed LINQ grouping queries are issued as two statements to fold the result set into the appropriate structure and any aggregates are performed client side against the result set, so your subsequent join against that result set is not supported server side. To work around this you would need to add a .ToList() after the .Select() aspect of the query which will cause the joins to be performed in memory but will allow this to work against the results of the grouping query. Another thing to keep in mind when writing LINQ queries is that while anything that is syntactically correct will compile, it may make absolutely no sense in practice or it may run into the limitations of the underlying provider which is where exceptions will be raised at run-time.
Jeremy |
|