<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dapper Tutorial &#8211; FoxDevelop</title>
	<atom:link href="https://www.foxdevelop.com/category/c-en/c-library/dapper-tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.foxdevelop.com</link>
	<description>Independent Software Developer Studio</description>
	<lastBuildDate>Thu, 06 Aug 2026 12:15:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://www.foxdevelop.com/wp-content/uploads/2026/05/fox-svgrepo-com-1.png</url>
	<title>Dapper Tutorial &#8211; FoxDevelop</title>
	<link>https://www.foxdevelop.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Introduction &#038; Installation</title>
		<link>https://www.foxdevelop.com/2026/08/06/introduction-installation/</link>
					<comments>https://www.foxdevelop.com/2026/08/06/introduction-installation/#respond</comments>
		
		<dc:creator><![CDATA[jack]]></dc:creator>
		<pubDate>Thu, 06 Aug 2026 12:15:06 +0000</pubDate>
				<category><![CDATA[Dapper Tutorial]]></category>
		<guid isPermaLink="false">https://www.foxdevelop.com/?p=7842</guid>

					<description><![CDATA[1. What Is Dapper Dapper is a .NET Micro ORM, widely known as the &#8220;King of Micro ORMs&#8221;, delivering performance close to raw ADO.NET. ORM: Object‑Relational Mapper, handles automatic mapping ...]]></description>
										<content:encoded><![CDATA[
<h4 class="wp-block-heading">1. What Is Dapper</h4>



<p class="wp-block-paragraph">Dapper is a <strong>.NET Micro ORM</strong>, widely known as the <strong>&#8220;King of Micro ORMs&#8221;</strong>, delivering performance close to raw ADO.NET.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">ORM: Object‑Relational Mapper, handles automatic mapping between database tables and C# entity objects.</p>
</blockquote>



<p class="wp-block-paragraph">Core features:</p>



<ol class="wp-block-list">
<li>Does not wrap SQL; developers write SQL statements manually;</li>



<li>Extends <code>IDbConnection</code> via <strong>extension methods</strong> (usable with any database connection object);</li>



<li>Lightweight footprint with excellent performance.</li>
</ol>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Note: Technically it is a <strong>Micro ORM</strong>, different from full‑featured ORM frameworks such as EF Core. There is ongoing community debate over whether it qualifies as a pure ORM.</p>
</blockquote>



<p class="wp-block-paragraph"><strong>Preventing SQL Injection</strong>: Use parameterized queries to avoid injection risks; concatenating raw SQL remains unsafe.</p>



<p class="wp-block-paragraph"><strong>Three‑Step Workflow</strong>: Create database connection → Write SQL statement → Call Dapper extension method to execute SQL with parameters.</p>



<h4 class="wp-block-heading">Features</h4>



<ul class="wp-block-list">
<li>High performance and fast query execution</li>



<li>Supports mapping to static entities and dynamic objects</li>



<li>Full control over SQL statements</li>



<li>Multi‑result‑set query support</li>



<li>Native stored‑procedure support</li>



<li>Built on the <code>IDbConnection</code> interface, compatible with most database drivers</li>



<li>Bulk insert support (extended capability; basic native bulk operations. For large‑scale bulk operations, use Dapper.Plus)</li>
</ul>



<h4 class="wp-block-heading">Installation</h4>



<h5 class="wp-block-heading">Option 1: NuGet Package Manager Console (PMC)</h5>


<pre class="wp-block-code"><span><code class="hljs">Install-Package Dapper</code></span></pre>


<h5 class="wp-block-heading">Option 2: .NET CLI (Recommended for .NET Core/.NET5+)</h5>


<pre class="wp-block-code"><span><code class="hljs">dotnet add package Dapper</code></span></pre>


<h5 class="wp-block-heading">Option 3: Visual Studio GUI</h5>



<p class="wp-block-paragraph">Solution Explorer → Right‑click your project → <strong>Manage NuGet Packages</strong>, search for <code>Dapper</code> and install it.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Important note: Dapper <strong>does not ship with database drivers</strong>!<br>For SQL Server install <code>Microsoft.Data.SqlClient</code> separately; for MySQL install <code>MySqlConnector</code>.</p>
</blockquote>



<h4 class="wp-block-heading">Example</h4>


<pre class="wp-block-code"><span><code class="hljs language-javascript">using Dapper;
using Microsoft.Data.SqlClient;

<span class="hljs-comment">// 1. Initialize IDbConnection</span>
string connStr = <span class="hljs-string">"Your database connection string"</span>;
using <span class="hljs-keyword">var</span> conn = <span class="hljs-keyword">new</span> SqlConnection(connStr);

<span class="hljs-comment">// 2. Define SQL</span>
string sql = <span class="hljs-string">"SELECT * FROM Article WHERE Id = @Id"</span>;

<span class="hljs-comment">// 3. Execute query and auto‑map to entity</span>
<span class="hljs-keyword">var</span> article = conn.QueryFirstOrDefault&lt;Article&gt;(sql, <span class="hljs-keyword">new</span> { Id = <span class="hljs-number">1</span> });

public <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Article</span>
</span>{
    public int Id { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
    public string Title { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
}</code></span></pre>


<h4 class="wp-block-heading">Comparison</h4>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Framework</th><th>Type</th><th>SQL Control</th><th>Use‑Cases</th></tr></thead><tbody><tr><td>Dapper</td><td>Micro ORM</td><td>Manual SQL writing</td><td>High‑performance requirements, complex queries, legacy project modernization</td></tr><tr><td>EF Core</td><td>Full ORM</td><td>Auto‑generated SQL, raw SQL also supported</td><td>Rapid development, simple business logic, avoid manual SQL</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">Introduction &amp; Installation</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.foxdevelop.com/2026/08/06/introduction-installation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
