{"id":96493,"date":"2023-11-15T08:12:11","date_gmt":"2023-11-15T07:12:11","guid":{"rendered":"https:\/\/code-maze.com\/?p=96493"},"modified":"2023-12-18T09:43:12","modified_gmt":"2023-12-18T08:43:12","slug":"database-row-as-json-using-dapper","status":"publish","type":"post","link":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/","title":{"rendered":"How to Get a Database Row as JSON Using Dapper"},"content":{"rendered":"<p>In this article, we will explore how to retrieve a database row as JSON using Dapper in the context of an ASP.NET Core Web API project. Our focus will be on data retrieval and serialization. We&#8217;ll exclude discussions of the intricacies of Dapper itself and the setup of the ASP.NET Core Web API project.<\/p>\n<div style=\"padding: 20px; border-left: 5px #dc2323 solid; display: block; margin-bottom: 20px; box-shadow: 1px 1px 5px 0px lightgrey;\">To download the source code for this article, you can visit our <a href=\"https:\/\/github.com\/CodeMazeBlog\/CodeMazeGuides\/tree\/main\/dotnet-dapper\/HowtoGetaDatabaseRowasJSONUsingDapper\" target=\"_blank\" rel=\"nofollow noopener\">GitHub repository<\/a>.<\/div>\n<p>So, let&#8217;s dive in.<\/p>\n<h2>Project Setup<\/h2>\n<p>We&#8217;ll begin by utilizing Dapper to retrieve entities from a database. Subsequently, we&#8217;ll use the <code>Newtonsoft.Json<\/code> library to serialize the acquired data into JSON format.<\/p>\n<p>Let&#8217;s install the necessary packages:<\/p>\n<ul>\n<li>Newtonsoft &#8211; <code>PM&gt; Install-Package Newtonsoft.Json<\/code><\/li>\n<li>Dapper &#8211; <code>PM&gt; Install-Package Dapper<\/code><\/li>\n<\/ul>\n<p>We will not go into details of Dapper setup in this article, but if you need a refresher, visit our <a href=\"https:\/\/code-maze.com\/using-dapper-with-asp-net-core-web-api\/\" target=\"_blank\" rel=\"noopener\">Using Dapper with ASP.NET Core Web API<\/a> article.<\/p>\n<h3>Interfaces and classes<\/h3>\n<p>We are going to adopt the Repository pattern along with a Service layer. To ensure a cohesive structure, we have defined <code>IRepository<\/code> and <code>IService<\/code> interfaces, both of which include a common <code>GetById<\/code> method:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">public interface IRepository\r\n{\r\n    public Task&lt;dynamic?&gt; GetById(int id);\r\n}\r\n\r\npublic interface IService\r\n{\r\n    public Task&lt;dynamic?&gt; GetById(int id);\r\n}<\/pre>\n<p>After setting up our interfaces, let&#8217;s proceed to create their corresponding class implementations starting with the <code>Service<\/code> class:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">public class Service : IService\r\n{\r\n    private readonly IRepository _repository;\r\n\r\n    public Service(IRepository repository)\r\n    {\r\n        _repository = repository;\r\n    }\r\n\r\n    public async Task&lt;dynamic?&gt; GetById(int id)\r\n    {\r\n        return await _repository.GetById(id);\r\n    }\r\n}<\/pre>\n<p>Here we simply inject our repository and use its <code>GetById<\/code> method.<\/p>\n<p>Next, we implement the <code>Repository<\/code> class:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">public class Repository : IRepository\r\n{\r\n    private readonly ILogger&lt;Repository&gt; _logger;\r\n    private readonly DapperContext _context;\r\n\r\n    public Repository(ILogger&lt;Repository&gt; logger, DapperContext context)\r\n    {\r\n        _logger = logger;\r\n        _context = context;\r\n    }\r\n\r\n    public async Task&lt;dynamic?&gt; GetById(int id) { \/\/ implementation shown below }\r\n}<\/pre>\n<p>Here we inject a logger along with the <code>DapperContext<\/code>, which we will use to query our database.<\/p>\n<p>Finally, let\u2019s register our interfaces and their implementations as a service in the <code>Program<\/code> class:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">builder.Services.AddScoped&lt;IRepository, Repository&gt;();\r\nbuilder.Services.AddScoped&lt;IService, Service&gt;();<\/pre>\n<h2>Getting a Database Row as JSON<\/h2>\n<p>Next, let&#8217;s implement the <code>GetById<\/code> method in our <code>Repository<\/code> class:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">public async Task&lt;dynamic?&gt; GetById(int id)\r\n{\r\n    const string query = \"SELECT * FROM Entities WHERE Id = @Id\";\r\n\r\n    using (var connection = _context.CreateConnection())\r\n    {\r\n        var entity = await connection.QuerySingleOrDefaultAsync(query, new { id });\r\n        if (entity != null)\r\n        {\r\n            string json = JsonConvert.SerializeObject(entity, Formatting.Indented);\r\n            _logger.LogInformation(\"Object as JSON {json}\", json);\r\n        }\r\n        else\r\n        {\r\n            _logger.LogInformation(\"Entity not found!\");\r\n        }\r\n        return entity;   \r\n    }\r\n}<\/pre>\n<p>The <code>GetById<\/code> method takes an <code>id<\/code> parameter representing the unique identifier of the entity we want to retrieve from the database. We then define a parameterized SQL query in the <code>query<\/code> variable. The query selects all columns from the <code>Entities<\/code> table where the <code>Id<\/code> matches the provided <code>Id<\/code>.<\/p>\n<p>We then use Dapper&#8217;s <code>QuerySingleOrDefaultAsync<\/code> method that executes a query asynchronously and returns a dynamic type or null. The result is then serialized to JSON by running: <code>JsonConvert.SerializeObject(entity, Formatting.Indented)<\/code>. The JSON result is then logged to the console.<\/p>\n<p>If you want to learn more about JSON and serialization in .NET visit our article <a href=\"https:\/\/code-maze.com\/csharp-object-into-json-string-dotnet\/\" target=\"_blank\" rel=\"noopener\">How to Turn a C# Object Into a JSON String in .NET<\/a><\/p>\n<p>Finally, the method returns the object, allowing the caller to work with the retrieved data.<\/p>\n<h3>API Controller<\/h3>\n<p>Now, let&#8217;s wrap up by creating a new <code>Controller<\/code>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">[ApiController]\r\n[Route(\"api\/entities\")]\r\npublic class Controller : ControllerBase\r\n{\r\n    private readonly ILogger&lt;Controller&gt; _logger;\r\n    private readonly IService _service;\r\n\r\n    public Controller(ILogger&lt;Controller&gt; logger, IService service)\r\n    {\r\n        _logger = logger;\r\n        _service = service;\r\n    }\r\n\r\n    [HttpGet(\"{id}\")]\r\n    public async Task&lt;IActionResult&gt; GetById(int id)\r\n    {\r\n        try\r\n        {\r\n            var entity = await _service.GetById(id);\r\n            return entity == null ? NotFound() : Ok(entity);\r\n         }\r\n         catch (Exception ex)\r\n         {\r\n             return StatusCode(500, ex.Message);\r\n         }\r\n     }\r\n}<\/pre>\n<p>Here we inject our service via Dependency Injection and use it to invoke the <code>GetById<\/code> method.<\/p>\n<p>The <code>GetById<\/code> method handles HTTP GET requests and expects <code>id<\/code> parameter as part of the URL. We asynchronously call the <code>GetById<\/code> method in the <code>service<\/code> class with the expected <code>id<\/code> parameter. To learn more about ASP.NET Core Web API services, be sure to check out our <a href=\"https:\/\/code-maze.com\/net-core-series\/\" target=\"_blank\" rel=\"noopener\">ASP.NET Core Web API<\/a> series.<\/p>\n<p>Finally, let&#8217;s start our application and use Postman for testing:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2023\/11\/dapper-row-to-json_get-request.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-96494 size-full\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2023\/11\/dapper-row-to-json_get-request.png\" alt=\"parameterized get request\" width=\"989\" height=\"575\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2023\/11\/dapper-row-to-json_get-request.png 989w, https:\/\/code-maze.com\/wp-content\/uploads\/2023\/11\/dapper-row-to-json_get-request-300x174.png 300w, https:\/\/code-maze.com\/wp-content\/uploads\/2023\/11\/dapper-row-to-json_get-request-768x447.png 768w\" sizes=\"auto, (max-width: 989px) 100vw, 989px\" \/><\/a><\/p>\n<p>We send a get request to our endpoint to retrieve a single entity.<\/p>\n<p>Upon inspecting the Console, we observe the log:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">{\r\n    \"Id\": 1,\r\n    \"Make\": \"Mercedes Benz\",\r\n    \"Model\": \"GLC\",\r\n    \"Year\": \"2014\",\r\n    \"Color\": \"Grey\"\r\n}<\/pre>\n<h2>Conclusion<\/h2>\n<p><span class=\"selectable-text copyable-text\">This article demonstrates how to retrieve a database row as JSON using Dapper. This approach is particularly helpful when building web APIs or services that must generate JSON responses based on database queries.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will explore how to retrieve a database row as JSON using Dapper in the context of an ASP.NET Core Web API project. Our focus will be on data retrieval and serialization. We&#8217;ll exclude discussions of the intricacies of Dapper itself and the setup of the ASP.NET Core Web API project. So, [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":62187,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1647],"tags":[22,898,889,927,50,130],"class_list":["post-96493","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dapper","tag-net-core","tag-net-core-web-api","tag-dapper","tag-json","tag-repository-pattern","tag-web-api","et-has-post-format-content","et_post_format-et-post-format-standard"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Get a Database Row as JSON Using Dapper - Code Maze<\/title>\n<meta name=\"description\" content=\"A comprehensive walkthrough of how to get a database row as JSON using Dapper and serialize it to JSON using NewtonSoft.Json Package\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Get a Database Row as JSON Using Dapper - Code Maze\" \/>\n<meta property=\"og:description\" content=\"A comprehensive walkthrough of how to get a database row as JSON using Dapper and serialize it to JSON using NewtonSoft.Json Package\" \/>\n<meta property=\"og:url\" content=\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/\" \/>\n<meta property=\"og:site_name\" content=\"Code Maze\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-15T07:12:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-18T08:43:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-aspnetcore.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"620\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Code Maze\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/CodeMazeBlog\" \/>\n<meta name=\"twitter:site\" content=\"@CodeMazeBlog\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Code Maze\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/\"},\"author\":{\"name\":\"Code Maze\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04\"},\"headline\":\"How to Get a Database Row as JSON Using Dapper\",\"datePublished\":\"2023-11-15T07:12:11+00:00\",\"dateModified\":\"2023-12-18T08:43:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/\"},\"wordCount\":525,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-aspnetcore.png\",\"keywords\":[\".NET CORE\",\".NET Core Web API\",\"Dapper\",\"JSON\",\"repository pattern\",\"Web API\"],\"articleSection\":[\"Dapper\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/\",\"url\":\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/\",\"name\":\"How to Get a Database Row as JSON Using Dapper - Code Maze\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-aspnetcore.png\",\"datePublished\":\"2023-11-15T07:12:11+00:00\",\"dateModified\":\"2023-12-18T08:43:12+00:00\",\"description\":\"A comprehensive walkthrough of how to get a database row as JSON using Dapper and serialize it to JSON using NewtonSoft.Json Package\",\"breadcrumb\":{\"@id\":\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#primaryimage\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-aspnetcore.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-aspnetcore.png\",\"width\":1100,\"height\":620,\"caption\":\"ASP.NET Core\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/code-maze.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Get a Database Row as JSON Using Dapper\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/code-maze.com\/#website\",\"url\":\"https:\/\/code-maze.com\/\",\"name\":\"Code Maze\",\"description\":\"Learn. Code. Succeed.\",\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/code-maze.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/code-maze.com\/#organization\",\"name\":\"Code Maze\",\"url\":\"https:\/\/code-maze.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"width\":3511,\"height\":3510,\"caption\":\"Code Maze\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/CodeMazeBlog\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04\",\"name\":\"Code Maze\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png\",\"caption\":\"Code Maze\"},\"description\":\"This is the standard author on the site. Most articles are published by individual authors, with their profiles, but when several authors have contributed, we publish collectively as a part of this profile.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/codemaze\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/CodeMazeBlog\"],\"url\":\"https:\/\/code-maze.com\/author\/codemazecontributor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Get a Database Row as JSON Using Dapper - Code Maze","description":"A comprehensive walkthrough of how to get a database row as JSON using Dapper and serialize it to JSON using NewtonSoft.Json Package","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/","og_locale":"en_US","og_type":"article","og_title":"How to Get a Database Row as JSON Using Dapper - Code Maze","og_description":"A comprehensive walkthrough of how to get a database row as JSON using Dapper and serialize it to JSON using NewtonSoft.Json Package","og_url":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/","og_site_name":"Code Maze","article_published_time":"2023-11-15T07:12:11+00:00","article_modified_time":"2023-12-18T08:43:12+00:00","og_image":[{"width":1100,"height":620,"url":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-aspnetcore.png","type":"image\/png"}],"author":"Code Maze","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/CodeMazeBlog","twitter_site":"@CodeMazeBlog","twitter_misc":{"Written by":"Code Maze","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#article","isPartOf":{"@id":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/"},"author":{"name":"Code Maze","@id":"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04"},"headline":"How to Get a Database Row as JSON Using Dapper","datePublished":"2023-11-15T07:12:11+00:00","dateModified":"2023-12-18T08:43:12+00:00","mainEntityOfPage":{"@id":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/"},"wordCount":525,"commentCount":0,"publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"image":{"@id":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-aspnetcore.png","keywords":[".NET CORE",".NET Core Web API","Dapper","JSON","repository pattern","Web API"],"articleSection":["Dapper"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/","url":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/","name":"How to Get a Database Row as JSON Using Dapper - Code Maze","isPartOf":{"@id":"https:\/\/code-maze.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#primaryimage"},"image":{"@id":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-aspnetcore.png","datePublished":"2023-11-15T07:12:11+00:00","dateModified":"2023-12-18T08:43:12+00:00","description":"A comprehensive walkthrough of how to get a database row as JSON using Dapper and serialize it to JSON using NewtonSoft.Json Package","breadcrumb":{"@id":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/code-maze.com\/database-row-as-json-using-dapper\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#primaryimage","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-aspnetcore.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-aspnetcore.png","width":1100,"height":620,"caption":"ASP.NET Core"},{"@type":"BreadcrumbList","@id":"https:\/\/code-maze.com\/database-row-as-json-using-dapper\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/code-maze.com\/"},{"@type":"ListItem","position":2,"name":"How to Get a Database Row as JSON Using Dapper"}]},{"@type":"WebSite","@id":"https:\/\/code-maze.com\/#website","url":"https:\/\/code-maze.com\/","name":"Code Maze","description":"Learn. Code. Succeed.","publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/code-maze.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/code-maze.com\/#organization","name":"Code Maze","url":"https:\/\/code-maze.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","width":3511,"height":3510,"caption":"Code Maze"},"image":{"@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/CodeMazeBlog"]},{"@type":"Person","@id":"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04","name":"Code Maze","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/person\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png","caption":"Code Maze"},"description":"This is the standard author on the site. Most articles are published by individual authors, with their profiles, but when several authors have contributed, we publish collectively as a part of this profile.","sameAs":["https:\/\/www.linkedin.com\/company\/codemaze\/","https:\/\/x.com\/https:\/\/twitter.com\/CodeMazeBlog"],"url":"https:\/\/code-maze.com\/author\/codemazecontributor\/"}]}},"_links":{"self":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/96493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/comments?post=96493"}],"version-history":[{"count":3,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/96493\/revisions"}],"predecessor-version":[{"id":96497,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/96493\/revisions\/96497"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media\/62187"}],"wp:attachment":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media?parent=96493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/categories?post=96493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/tags?post=96493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}