{"record":{"id":"a2fbe8e62ffbeafe","repo":"dotnet/efcore","slug":"arraycreation-multi-dimensional-array-implicita","errorCode":null,"errorMessage":"ArrayCreation: multi-dimensional array: {implicitArrayCreation}","messagePattern":"ArrayCreation: multi-dimensional array: (.+?)","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs","lineNumber":477,"sourceCode":"            $\"Encountered unknown identifier name '{identifierName}', which doesn't correspond to a lambda parameter or captured variable\");\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public override Expression VisitImplicitArrayCreationExpression(ImplicitArrayCreationExpressionSyntax implicitArrayCreation)\n    {\n        if (_semanticModel.GetTypeInfo(implicitArrayCreation).Type is not IArrayTypeSymbol arrayTypeSymbol)\n        {\n            throw new InvalidOperationException($\"ArrayCreation: non-array type symbol: {implicitArrayCreation}\");\n        }\n\n        if (arrayTypeSymbol.Rank > 1)\n        {\n            throw new NotImplementedException($\"ArrayCreation: multi-dimensional array: {implicitArrayCreation}\");\n        }\n\n        var elementType = ResolveType(arrayTypeSymbol.ElementType);\n        Check.DebugAssert(elementType is not null);\n\n        var initializers = implicitArrayCreation.Initializer.Expressions.Select(e => Visit(e));\n\n        return NewArrayInit(elementType, initializers);\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public override Expression VisitInterpolatedStringExpression(InterpolatedStringExpressionSyntax interpolatedString)\n    {","sourceCodeStart":459,"sourceCodeEnd":495,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs#L459-L495","documentation":"VisitImplicitArrayCreationExpression throws NotImplementedException when the resolved array type has Rank > 1. Precompiled query translation only supports single-dimensional arrays; multi-dimensional arrays (int[,], string[,,]) cannot be represented via the supported NewArrayInit path.","triggerScenarios":"A multi-dimensional array literal such as new[,] { { 1, 2 }, { 3, 4 } } or new int[2, 2] appears inside a precompiled query expression.","commonSituations":"Matrix/grid/image data structures, board-game state, or math code using T[,] being constructed inside a query that gets precompiled.","solutions":["Replace the multi-dimensional array with a jagged array (T[][]) which is supported","Move the array construction out of the query into a captured local computed beforehand","Flatten the data into a single-dimensional array and compute indices manually"],"exampleFix":"// before\nvar m = new[,] { { 1, 2 }, { 3, 4 } };\n// after\nvar m = new int[][] { new[] { 1, 2 }, new[] { 3, 4 } };","handlingStrategy":"validation","validationCode":"// Reject multi-dimensional arrays in precompiled query source.\nstatic bool UsesMultidimArray(string querySource)\n    => System.Text.RegularExpressions.Regex.IsMatch(querySource, @\"new\\s*\\[\\s*,\");\nif (UsesMultidimArray(querySource)) { /* rewrite to jagged or hoist */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer jagged arrays (T[][]) over multi-dimensional arrays (T[,]) for data used in queries","Compute multi-dimensional data outside the query and capture it in a local","Review any T[,] declarations near precompiled query code"],"tags":["efcore","precompiled-queries","arrays","csharp"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}