{"record":{"id":"9592c1225c162527","repo":"litedb-org/LiteDB","slug":"method-reflection-methodname-node-method-in-no","errorCode":null,"errorMessage":"Method {Reflection.MethodName(node.Method)} in {node.Method.DeclaringType.Name} are not supported when convert to BsonExpression ({node.ToString()}).","messagePattern":"Method (.+?) in (.+?) are not supported when convert to BsonExpression \\((.+?)\\)\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"LiteDB/Client/Mapper/Linq/LinqExpressionVisitor.cs","lineNumber":241,"sourceCode":"            if (!hasResolver)\n            {\n                // if method are called by parameter expression and it's not exists, throw error\n                var isParam = ParameterExpressionVisitor.Test(node);\n\n                if (isParam) throw new NotSupportedException($\"Method {node.Method.Name} not available to convert to BsonExpression ({node.ToString()}).\");\n\n                // otherwise, try compile and execute\n                var value = this.Evaluate(node);\n\n                base.Visit(Expression.Constant(value));\n\n                return node;\n            }\n\n            // otherwise I have resolver for this method\n            var pattern = type.ResolveMethod(node.Method);\n\n            if (pattern == null) throw new NotSupportedException($\"Method {Reflection.MethodName(node.Method)} in {node.Method.DeclaringType.Name} are not supported when convert to BsonExpression ({node.ToString()}).\");\n\n            // run pattern using object as # and args as @n\n            this.ResolvePattern(pattern, node.Object, node.Arguments);\n\n            return node;\n        }\n\n        /// <summary>\n        /// Visit :: x => x.Age + `10` (will create parameter:  `p0`, `p1`, ...)\n        /// </summary>\n        protected override Expression VisitConstant(ConstantExpression node)\n        {\n            var value = node.Value;\n\n            // https://stackoverflow.com/a/29708655/3286260\n            foreach (var memberAccessNode in _memberAccessNodes)\n            {\n                if (memberAccessNode.Member is FieldInfo fieldInfo)","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/litedb-org/LiteDB/blob/f906a5f850678719e39a39a006cb66dcae563cfa/LiteDB/Client/Mapper/Linq/LinqExpressionVisitor.cs#L223-L259","documentation":"Thrown by VisitMethodCall when a resolver DOES exist for the method's declaring type but ResolveMethod returns null for the specific method overload. The declaring type is recognized, but this particular method (or overload) is not in the resolver's known set. The full method signature is shown via Reflection.MethodName for clarity.","triggerScenarios":"Calling a method on a resolver-backed type using an unsupported overload. For example x => x.Name.IndexOf(\"ab\", StringComparison.OrdinalIgnoreCase) where StringResolver does not support that specific IndexOf overload, or x => x.Value.ToString(\"X\") on a numeric type whose resolver lacks that pattern.","commonSituations":"Using an uncommon overload of a supported method (different parameter count or types). Passing format strings or comparison options that the resolver does not handle. Upgrading LiteDB and finding a previously-tolerated overload now explicitly rejected.","solutions":["Use a supported overload of the method (e.g., the parameterless or single-argument variant that the resolver recognizes).","Hoist the computation into a closure variable if it produces a constant for the query.","Use a raw BsonExpression string if the equivalent operation is supported in BsonExpression syntax.","Check the type resolver source (e.g., StringResolver, DateTimeResolver) for the exact supported method list."],"exampleFix":"// before\ncol.Find(x => x.Name.IndexOf(\"ab\", 0, StringComparison.OrdinalIgnoreCase) >= 0);\n\n// after -- use the supported Contains overload\ncol.Find(x => x.Name.Contains(\"ab\"));","handlingStrategy":"validation","validationCode":"// Check the resolver source for supported method overloads before using them\n// StringResolver supports: Contains, StartsWith, EndsWith, ToUpper, ToLower, Substring\n// Avoid unsupported overloads (e.g., IndexOf with StringComparison)\nvar test = mapper.GetExpression<MyEntity, bool>(x => x.Name.Contains(\"abc\"));","typeGuard":null,"tryCatchPattern":"try\n{\n    var results = col.Find(x => x.Name.IndexOf(\"ab\", StringComparison.OrdinalIgnoreCase) >= 0);\n}\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"are not supported when convert to BsonExpression\"))\n{\n    results = col.Find(x => x.Name.Contains(\"ab\"));\n}","preventionTips":["Use only the simplest overload of a method in LINQ queries (fewest parameters).","Check the resolver source code for the exact supported method signatures.","Hoist constant computations (like format strings) out of the query expression.","Write unit tests per query predicate to validate translation succeeds."],"tags":["linq","method-call","resolver"],"backgroundTag":null,"analyzedSha":"f906a5f850678719e39a39a006cb66dcae563cfa","analyzedAt":"2026-08-13T21:56:30.148Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}