I am using Lightspeed v4.0.1632.21637 (nightly 16 Oct 2012) on the Nortwind database. I try to group on two columns, from different tables:
var results = from product in uow.Products
join category in uow.Categories on product.CategoryId equals category.Id
select new { product, category } into combined
group combined by new { combined.product.SupplierId, combined.category.CategoryName } into g
select new { g.Key.CategoryName };
I get the following exception:
System.ArgumentException: Object of type 'Mindscape.LightSpeed.Linq.Grouping`2[<>f__AnonymousType3`2[System.Nullable`1[System.Int32],System.String],Northwind.Library.Products]' cannot be converted to type 'System.Linq.IGrouping`2[<>f__AnonymousType3`2[System.Nullable`1[System.Int32],System.String],<>f__AnonymousType2`2[Northwind.Library.Products,Northwind.Library.Categories]]'.
at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at Mindscape.LightSpeed.Linq.Plan.LinqQueryPlanExpression.Project(IList set, IList`1 projectors)
at Mindscape.LightSpeed.Linq.Plan.GroupResultsPlan.GetAllGroupsAtOnce(IUnitOfWork unitOfWork, IList groupingKeys, IList interimKeys, List`1 groupingOn, GroupResultsTypeHandler handler)
at Mindscape.LightSpeed.Linq.Plan.GroupResultsPlan.FetchResultSetForMultipleGroupingKeys(IUnitOfWork unitOfWork, IList groupingKeys, IList interimKeys, GroupResultsTypeHandler handler)
at Mindscape.LightSpeed.Linq.Plan.GroupResultsPlan.ExecuteImmediate(IUnitOfWork unitOfWork, Type returnType)
at Mindscape.LightSpeed.Linq.LinqQueryProvider.Execute(Expression expression)
at Mindscape.LightSpeed.Linq.LinqQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression)
at Mindscape.LightSpeed.Linq.LinqQuery`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList(IEnumerable`1 source)
at Northwind.Tests.LightspeedTest.GroupOnTwoTables() in LightspeedTest.cs: line 45