{"record":{"id":"94e107aebe433909","repo":"DapperLib/Dapper","slug":"type-94e107","errorCode":null,"errorMessage":"type","messagePattern":"type","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Dapper/SqlMapper.GridReader.cs","lineNumber":130,"sourceCode":"            /// </summary>\r\n            /// <typeparam name=\"T\">The type to read.</typeparam>\r\n            public T ReadSingle<T>() => ReadRow<T>(typeof(T), Row.Single);\r\n\r\n            /// <summary>\r\n            /// Read an individual row of the next grid of results.\r\n            /// </summary>\r\n            /// <typeparam name=\"T\">The type to read.</typeparam>\r\n            public T? ReadSingleOrDefault<T>() => ReadRow<T>(typeof(T), Row.SingleOrDefault);\r\n\r\n            /// <summary>\r\n            /// Read the next grid of results.\r\n            /// </summary>\r\n            /// <param name=\"type\">The type to read.</param>\r\n            /// <param name=\"buffered\">Whether to buffer the results.</param>\r\n            /// <exception cref=\"ArgumentNullException\"><paramref name=\"type\"/> is <c>null</c>.</exception>\r\n            public IEnumerable<object> Read(Type type, bool buffered = true)\r\n            {\r\n                if (type is null) throw new ArgumentNullException(nameof(type));\r\n                return ReadImpl<object>(type, buffered);\r\n            }\r\n\r\n            /// <summary>\r\n            /// Read an individual row of the next grid of results.\r\n            /// </summary>\r\n            /// <param name=\"type\">The type to read.</param>\r\n            /// <exception cref=\"ArgumentNullException\"><paramref name=\"type\"/> is <c>null</c>.</exception>\r\n            public object ReadFirst(Type type)\r\n            {\r\n                if (type is null) throw new ArgumentNullException(nameof(type));\r\n                return ReadRow<object>(type, Row.First);\r\n            }\r\n\r\n            /// <summary>\r\n            /// Read an individual row of the next grid of results.\r\n            /// </summary>\r\n            /// <param name=\"type\">The type to read.</param>\r","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/DapperLib/Dapper/blob/72a54c475f75e18cb93cba0809d00a5e6e49efd9/Dapper/SqlMapper.GridReader.cs#L112-L148","documentation":"GridReader.Read(Type type, bool buffered) is the synchronous non-generic overload that reads the next grid into instances of a runtime Type, throwing ArgumentNullException(nameof(type)) at SqlMapper.GridReader.cs:130 when type is null. The generic Read<T> overload cannot hit this.","triggerScenarios":"Call grid.Read((Type)null) — usually a Type variable from reflection or a lookup that returned null.","commonSituations":"Type.GetType returning null for an unresolvable assembly-qualified name; dispatch tables with a missing mapping; conditional Type selection without an else.","solutions":["Null-check the Type before calling and surface the unresolved name.","Use the generic Read<T>() overload to make the error a compile-time one.","Centralize Type resolution in a helper that throws on null."],"exampleFix":"// before\nType t = Type.GetType(name); // null if unresolved\nvar rows = grid.Read(t);\n\n// after\nType t = Type.GetType(name) ?? throw new InvalidOperationException($\"Unresolved type {name}\");\nvar rows = grid.Read(t);","handlingStrategy":"validation","validationCode":"if (type is null) throw new InvalidOperationException(\"type must be resolved before reading a grid\");\nvar rows = grid.Read(type);","typeGuard":"Type t = Type.GetType(name) ?? throw new InvalidOperationException($\"Unresolved type {name}\");","tryCatchPattern":null,"preventionTips":["Prefer generic Read<T>().","Resolve Types at startup and reject nulls with a named error.","Use assembly-qualified names with Type.GetType."],"tags":["dapper","gridreader","argumentnullexception","type-resolution"],"backgroundTag":null,"analyzedSha":"72a54c475f75e18cb93cba0809d00a5e6e49efd9","analyzedAt":"2026-08-13T14:18:18.115Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}