I've recently upgraded the .NET MongoDB Drivers from the Legacy ones to the newer ones. Lots of the queries don't work any more, this one has me stumped.
var dataSource = permissions.Select(x => new PermissionSetPermissionGridViewModel
{
Id = x.Id,
PermissionGroupInfo = new KeyValuePair<Guid?, string>(x.PermissionGroupId, TitleHelper.GetPermissionGroupTitle(x.PermissionGroupId)),
IsEnabled = x.IsEnabled,
ObjectType = ObjectTypeIds.GetEnumValue(x.ObjectTypeId.Value)
}).ToList()
It doesn't seem to support the Static function TitleHelper.GetPermissionGroup() producing the following error.
[NotSupportedException]: GetPermissionGroupTitle of type Saturn.WebUI.Core.Helpers.TitleHelper is not supported in the expression tree GetPermissionGroupTitle({document}{PermissionGroupId}).
at MongoDB.Driver.Linq.Translators.AggregateLanguageTranslator.TranslateMethodCall(MethodCallExpression node)
at MongoDB.Driver.Linq.Translators.AggregateLanguageTranslator.TranslateMapping(ProjectionMapping mapping)
at MongoDB.Driver.Linq.Translators.AggregateLanguageTranslator.TranslateMapping(ProjectionMapping mapping)
at MongoDB.Driver.Linq.Translators.AggregateLanguageTranslator.TranslateValue(Expression node)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateProjectValue(Expression selector)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateSelect(SelectExpression node)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslatePipeline(PipelineExpression node)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node, IBsonSerializerRegistry serializerRegistry, ExpressionTranslationOptions translationOptions)
at MongoDB.Driver.Linq.MongoQueryProviderImpl`1.Execute(Expression expression)
at MongoDB.Driver.Linq.MongoQueryableImpl`2.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Saturn.WebUI.Areas.Security.Controllers.PermissionSetRecordController.GetStaticPermissions(DataSourceRequest request, Guid permissionSetId) in C:\work\saturn-develop\saturn\src\Saturn.WebUI\Areas\Security\Controllers\PermissionSetRecordController.cs:line 87
How can I refactor this query so that It is supported by the newer drivers?