You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a ASP.NET Core API. When I'm trying to get parent/child results from single dataset from SQL Server stored procedure, I got System.NullReferenceException: "Object reference not set to an instance of an object." error.
public class PriorityModel
{
[RecordId]
public int Id { get; set; }
[ParentRecordId]
public int? ParentId { get; set; }
public int IndexNumber { get; set; }
[Column(SerializationMode = SerializationMode.Json)]
public required IEnumerable<LocalizedNameModel> Name { get; set; }
[ChildRecords]
public IList<PriorityModel>? Children { get; set; }
}
public class LocalizedNameModel
{
public required string Key { get; set; }
public required string Value { get; set; }
}
Controller
public IActionResult GetPriorities(bool showOnlyTopLevel, bool showAllLanguages, string language = "en")
{
using var cnn = new SqlConnection(connectionString);
var result = cnn.Query("ref.GetPriorities", new { showOnlyTopLevel, showAllLanguages, language },
Query.Returns(Together<PriorityModel, PriorityModel>.Records));
return Ok(result);
}
Describe the bug
I have a ASP.NET Core API. When I'm trying to get parent/child results from single dataset from SQL Server stored procedure, I got System.NullReferenceException: "Object reference not set to an instance of an object." error.
Steps to reproduce
Expected behavior
I expect following JSON on exit:
The text was updated successfully, but these errors were encountered: