I don't have Visual Studio available ATM, but I'll try to have a look
at your code on Tuesday.
Best regards,
Fabian
> --
> You received this message because you are subscribed to the Google Groups
> "re-motion Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/re-motion-users/-/1_NZuXW6Hf4J.
> To post to this group, send email to re-moti...@googlegroups.com.
> To unsubscribe from this group, send email to
> re-motion-use...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/re-motion-users?hl=en.
I've looked at the exception you're getting, and it seems that you've
got a type problem.
You're transforming this query:
from IGrouping`2 myGrp in
{
from Stock data in value(RelinqProj.COALQueryable`1[RelinqProj.Stock])
where ([data].CloseDate >= 10.04.2012 17:19:08)
select [data]
=> GroupBy(new <>f__AnonymousType0`1(Region = [data].Region), [data])
}
select new <>f__AnonymousType1`2(Region = [myGrp].Key.Region, Col2 =
{from Stock d in [myGrp] select [d].Close => Sum()})
into this one
from Stock data in value(RelinqProj.COALQueryable`1[RelinqProj.Stock])
where ([data].CloseDate >= 10.04.2012 17:27:57)
select new <>f__AnonymousType1`2(Region = new
<>f__AnonymousType0`1(Region = [data].Region).Region, Col2 =
Aggregated (Aggregated (Aggregated ([d].Close))))
=> GroupBy(new <>f__AnonymousType0`1(Region = [data].Region), [data])
You're performing the transformation in-place, i.e., you're modifying
the QueryModel (rather than generating some kind of "backend" data
structure). When you perform a replacement in-place, you should take
extra care not to change the type of the QueryModel's results because
the code that executes the query expects the results to be of that
type.
You're getting this exception:
'System.Linq.IQueryable`1[<>f__AnonymousType1`2[System.String,System.Double]]'
cannot be used as the data type for a sequence with an ItemExpression
of type 'System.Linq.IGrouping`2[<>f__AnonymousType0`1[System.String],RelinqProj.Stock]'.
While the exception message probably isn't too clear in this context
(I've added a JIRA ticket to improve it), the reason is that the
caller expects items of type AnonymousType1`2, while your transformed
query would given them items of type IGrouping<AnonymousType0`1>.
The solution is to ensure that the results of the transformed query
still have the right type.
Regards,
Fabian