Datagrid Export Errror

I get an error when clicking Export for Excel or CSV.

System.Reflection.AmbiguousMatchException: Ambiguous match found.
at System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
at System.Type.GetProperty(String name, BindingFlags bindingAttr)
at System.Linq.Dynamic.Core.Parser.ExpressionParser.CreateNewExpression(List1 properties, List1 expressions, Type newType)
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseNew()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseIdentifier()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParsePrimaryStart()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParsePrimary()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseUnary()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseMultiplicative()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAdditive()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseShiftOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseComparisonOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLogicalAndOrOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseIn()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAndOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseOrOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLambdaOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseNullCoalescingOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseConditionalOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.Parse(Type resultType, Boolean createParameterCtor)
at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(ParsingConfig parsingConfig, Boolean createParameterCtor, ParameterExpression[] parameters, Type resultType, String expression, Object[] values)
at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(ParsingConfig parsingConfig, Boolean createParameterCtor, Type itType, Type resultType, String expression, Object[] values)
at System.Linq.Dynamic.Core.DynamicQueryableExtensions.Select(IQueryable source, ParsingConfig config, String selector, Object[] args)
at System.Linq.Dynamic.Core.DynamicQueryableExtensions.Select(IQueryable source, String selector, Object[] args)
at PartnerLink3.ExportController.ApplyQuery[T](IQueryable`1 items, IQueryCollection query) in C:\Users\JohnFuqua\source\repos\PartnerLink3\server\Controllers\ExportController.cs:line 57
at PartnerLink3.ExportPartnerLinkDbController.ExportOrdersToExcel(String fileName) in C:\Users\JohnFuqua\source\repos\PartnerLink3\server\Controllers\ExportPartnerLinkDbController.cs:line 262
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Any info about the export settings? Do you have any $expand and $select parameters?

No. It's just the standard generated datagrid with an added Orderby parameter.

Will you post a screenshot from Radzen with export method details?

Button Click code:

 if (args?.Value == "csv")
            {
                await IntegriFlowDocuments.ExportDocumentFormatsToCSV(new Query() { Filter = $@"{grid0.Query.Filter}", OrderBy = $"{grid0.Query.OrderBy}", Expand = "", Select = "DocumentFormatID,Name,ModifiedOn,ModifiedBy,CreatedOn,CreatedBy" }, $"Document Formats");

            }

            if (args == null || args.Value == "xlsx")
            {
                await IntegriFlowDocuments.ExportDocumentFormatsToExcel(new Query() { Filter = $@"{grid0.Query.Filter}", OrderBy = $"{grid0.Query.OrderBy}", Expand = "", Select = "DocumentFormatID,Name,ModifiedOn,ModifiedBy,CreatedOn,CreatedBy" }, $"Document Formats");

            }

Export method code:

 public async Task ExportDocumentFormatsToExcel(Query query = null, string fileName = null)
        {
            navigationManager.NavigateTo(query != null ? query.ToUrl($"export/integriflowdocuments/documentformats/excel(fileName='{(!string.IsNullOrEmpty(fileName) ? UrlEncoder.Default.Encode(fileName) : "Export")}')") : $"export/integriflowdocuments/documentformats/excel(fileName='{(!string.IsNullOrEmpty(fileName) ? UrlEncoder.Default.Encode(fileName) : "Export")}')", true);
        }

        public async Task ExportDocumentFormatsToCSV(Query query = null, string fileName = null)
        {
            navigationManager.NavigateTo(query != null ? query.ToUrl($"export/integriflowdocuments/documentformats/csv(fileName='{(!string.IsNullOrEmpty(fileName) ? UrlEncoder.Default.Encode(fileName) : "Export")}')") : $"export/integriflowdocuments/documentformats/csv(fileName='{(!string.IsNullOrEmpty(fileName) ? UrlEncoder.Default.Encode(fileName) : "Export")}')", true);
        }```

It’s not what I asked for but still it’s visible that you have select parameters even though you’ve said that you don’t have. Try to remove them (from Radzen not from the generated code since the code will be overwritten on next run unless put in ignore list) and test to see if the export will work.

I'm kind of new to your tool...can you point me where to do this? on the Datagrid? Export? Page Load?
I'm assuming this is done in the designer?

Yes, you can check the export button Click event. There is a Export action invoke with parameters.

Which ones do you want me to get rid of?

You have $expand parameters as well. Most probably you have a property name of the main object equal to a property name of a sub object. For example Name and SubObject.Name in $select parameters. If this is the case you can change the SubObject.Name to SubObject.Name as SomeName.

Ok...I have names that are the same coming from different tables/entities.

Supplier.Name,Customer.Name,InvoiceDate,Gross,DetailInvoiceNumber,PONumber,Status.Name

Should I use an "As" modifier on them?

That worked. Thanks for the help.