Overview
Cuemon.Extensions.Data adds extension-method entry points on top of Cuemon.Data and System.Data so common reader, type-mapping, and query-fragment tasks can be expressed against familiar framework abstractions. Instead of introducing another data-access layer, it attaches concise operations to IDataReader, DbType, and QueryFormat.
The package stays close to the lower-level Cuemon data model. It turns materialization and formatting steps into single calls while leaving connection management, command execution, and provider-specific concerns to Cuemon.Data and the underlying ADO.NET provider.
Key APIs
ToRows converts an IDataReader into a DataTransferRowCollection by delegating to DataTransfer.GetRows(reader). Use it when you want the full result set materialized with row iteration and shared column metadata instead of manually copying values out of the reader.
ToColumns converts a read-initialized IDataReader into a DataTransferColumnCollection. It is meant for the current row only, so the reader must already be positioned with Read() before the call.
ToType maps a DbType value to the corresponding CLR Type. The implementation routes through the underlying Cuemon.Data decorator model and throws ArgumentOutOfRangeException when the enum value is unsupported.
Embed formats int, long, or string sequences as query fragments using a QueryFormat such as Delimited, DelimitedString, or DelimitedSquareBracket. The overloads also support distinct: true so repeated values can be collapsed before the fragment is emitted.
Basic usage
using Cuemon.Data;
using Cuemon.Extensions.Data;
using Codebelt.Extensions.Xunit;
using Xunit;
namespace MyProject.Tests;
public class QueryFormatEmbedTest : Test
{
public QueryFormatEmbedTest(ITestOutputHelper output) : base(output)
{
}
[Fact]
public void Embed_ShouldBuildDistinctStringFragmentForSqlFilter()
{
var requestedStates = new[] { "Pending", "Shipped", "Pending" };
var stateFilter = QueryFormat.DelimitedString.Embed(requestedStates, distinct: true);
var whereClause = $"Status IN ({stateFilter})";
TestOutput.WriteLine(whereClause);
Assert.Equal("'Pending','Shipped'", stateFilter);
Assert.Equal("Status IN ('Pending','Shipped')", whereClause);
}
}
Use this pattern when a caller needs to turn a typed value set into a database-friendly fragment without manually quoting or deduplicating each element. It matters because the package keeps query-shaping code short while still making the chosen formatting rule explicit at the call site.
Installation
dotnet add package Cuemon.Extensions.Data
Usage guidance
Adopt Cuemon.Extensions.Data when your code already works with Cuemon.Data or raw ADO.NET and you want terse conversions from readers to transfer collections, DbType to CLR types, or QueryFormat values to reusable SQL fragments. Prefer Cuemon.Data directly when you need the underlying reader helpers and transfer objects themselves, and stick with plain framework APIs when a one-off reader loop or handwritten fragment is clearer than adding extension-method syntax.
Family packages
- 🌐Cuemon.AspNetCore
- 🏭Cuemon.AspNetCore.App
- 🌐Cuemon.AspNetCore.Authentication
- 🌐Cuemon.AspNetCore.Mvc
- 🌐Cuemon.AspNetCore.Razor.TagHelpers
- 📦Cuemon.Core
- 🏭Cuemon.Core.App
- 🗄️Cuemon.Data
- 🗄️Cuemon.Data.Integrity
- 🗄️Cuemon.Data.SqlClient
- 🩺Cuemon.Diagnostics
- 🌐Cuemon.Extensions.AspNetCore
- 🌐Cuemon.Extensions.AspNetCore.Authentication
- 🌐Cuemon.Extensions.AspNetCore.Mvc
- 🌐Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json
- 🌐Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml
- 🌐Cuemon.Extensions.AspNetCore.Mvc.RazorPages
- 🌐Cuemon.Extensions.AspNetCore.Text.Json
- 🌐Cuemon.Extensions.AspNetCore.Xml
- 📦Cuemon.Extensions.Collections.Generic
- 📦Cuemon.Extensions.Collections.Specialized
- 📦Cuemon.Extensions.Core
- 🗄️Cuemon.Extensions.Data.Integrity
- 📦Cuemon.Extensions.DependencyInjection
- 🩺Cuemon.Extensions.Diagnostics
- 🏗️Cuemon.Extensions.Hosting
- 📦Cuemon.Extensions.IO
- 📦Cuemon.Extensions.Net
- 📦Cuemon.Extensions.Reflection
- 📦Cuemon.Extensions.Runtime.Caching
- 📝Cuemon.Extensions.Text
- 📝Cuemon.Extensions.Text.Json
- 📦Cuemon.Extensions.Threading
- 📦Cuemon.Extensions.Xml
- 📦Cuemon.IO
- ⚙️Cuemon.Kernel
- 📦Cuemon.Net
- 📦Cuemon.Resilience
- 📦Cuemon.Runtime.Caching
- 🔐Cuemon.Security.Cryptography
- 📦Cuemon.Threading
- 📦Cuemon.Xml