PocoDataSet.SqlServerDataAdapter
1.0.32
See the version list below for details.
dotnet add package PocoDataSet.SqlServerDataAdapter --version 1.0.32
NuGet\Install-Package PocoDataSet.SqlServerDataAdapter -Version 1.0.32
<PackageReference Include="PocoDataSet.SqlServerDataAdapter" Version="1.0.32" />
<PackageVersion Include="PocoDataSet.SqlServerDataAdapter" Version="1.0.32" />
<PackageReference Include="PocoDataSet.SqlServerDataAdapter" />
paket add PocoDataSet.SqlServerDataAdapter --version 1.0.32
#r "nuget: PocoDataSet.SqlServerDataAdapter, 1.0.32"
#:package PocoDataSet.SqlServerDataAdapter@1.0.32
#addin nuget:?package=PocoDataSet.SqlServerDataAdapter&version=1.0.32
#tool nuget:?package=PocoDataSet.SqlServerDataAdapter&version=1.0.32
PocoDataSet
The POCO DataSet documentation is published in the "POCO DataSet" section of businessprocessprogramming.net website.
PocoDataSet is a lightweight, in-memory DataSet / DataTable / DataRow model built around simple POCOs and interfaces.
It is designed to be:
- UI-friendly – works well with Blazor, WPF, WinUI, etc.
- POCO-based – data is represented as plain C# objects, not tied to any specific framework.
- Extensible – core contracts live in
PocoDataSet.IData, with implementations and helpers in separate projects.
Project structure
The solution contains the following projects:
PocoDataSet.IData
Interfaces and contracts only:IDataSet,IDataTable,IDataRowIColumnMetadata,IDataRelation,IForeignKeyDataIDataSetValidator,IMergeOptionsIValueConverter(for pluggable value conversion)
Interfaces and contracts for the merge infrastructure:
IDataSetMergeEngine– orchestrates DataSet / DataTable / DataRow mergeIDataSetMergeConfiguration– provides merge policies and handlersITableMergeHandler– table-level merge behaviorIRowMergeHandler– row-level merge behavior
PocoDataSet.Data
Concrete implementations of the interfaces:DataSet– holds a dictionary of named tables and relationsDataTable– holds columns and rowsDataRow– a dictionary-backed row with helper methods and state (RowState,Selected)ColumnMetadata,DataRelation,ForeignKeyData
PocoDataSet.Extensions
Convenience extension methods and helpers:DataSetExtensionsAddTable,AddNewTable,AddRow,RemoveRow,RemoveTableGetTable,GetRequiredTable,TryGetTable,GetFieldValue<T>MergeWithand related merge helpers
DataTableExtensionsAddColumn,AddColumnsAddColumnsFromInterface(build schema from a .NET interface)
DataRowExtensionsCreateRowFromColumns,CreateRowFromColumnsWithDefaultValuesGetDataFieldValue<T>(with friendly conversion)CopyFromPoco,ToPoco,MergeWith
DataSetFactoryCreateDataSet()– simple factory forIDataSet
- Internal helpers (data type names, default value helpers, type info, etc.)
Default implementation of the merge infrastructure:
DataSetMergeEngine– handler-based merge engineDataSetMergeConfiguration– default configuration and wiringDefaultTableMergeHandler– primary-key based table mergeDefaultRowMergeHandler– value-level row mergeDataTypeDefaultValueProvider– default metadata-to-value mapping
PocoDataSet.IObservableData
Interfaces and contracts for the observable layer (UI reactivity support):IObservableDataSet,IObservableDataTable,IObservableDataRow,IObservableDataView- Event args such as
RowsChangedEventArgsandDataFieldValueChangedEventArgs
This project contains contracts only and has no runtime dependencies on UI frameworks.
PocoDataSet.ObservableData
Concrete implementations of the observable contracts:ObservableDataSet– wraps anIDataSetand bubbles table / row eventsObservableDataTable– wraps anIDataTableand tracks observable rowsObservableDataRow– wraps anIDataRowand raisesDataFieldValueChangedObservableDataView– per-control view over a table (filter/sort) with deterministic disposal
Notes:
ObservableDataSetowns created views and disposes them when the source table is removed.ObservableDataViewsubscribes to table events and maintains its own row list; it unsubscribes on dispose.
PocoDataSet.ObservableExtensions
Convenience extension methods to bridge POCO DataSet and the observable layer:- Create observable wrappers from
IDataSet/IDataTable - Helpers for common UI scenarios (one view per control instance, etc.)
- Create observable wrappers from
PocoDataSet.Serializer
JSON serialization helpers usingSystem.Text.Json:DataSetSerializer.FromJsonString(string? json) : IDataSet?DataSetSerializer.ToJsonString(IDataSet dataSet) : string
PocoDataSet.SqlServerDataAdapter
ThePocoDataSet.SqlServerDataAdapterproject provides a lightweight SQL Server adapter that fillsPocoDataSetin-memoryIDataSet/IDataTablestructures from T-SQL queries. It is intended as an example/utility that demonstrates reading schema, primary key and foreign key information and populatingPocoDataSet.Datamodel objects.
Purpose
- Execute queries against SQL Server and populate
IDataSet/IDataTable/IDataRow. - Preserve table/column metadata (column names, data types, max length, primary keys, foreign keys, nullability).
- Provide an async-friendly
FillAsyncAPI that accepts parameter dictionaries to avoid inline concatenation and reduce risk of SQL injection.
Key types
PocoDataSet.SqlServerDataAdapter.SqlDataAdapter— main adapter class used to execute queries and return anIDataSet.PocoDataSet.SqlServerDataAdapter.DataTableCreator— internal helper used by the adapter to createDataTableinstances with columns, primary keys and rows.PocoDataSet.SqlServerDataAdapter.ForeignKeyData— holds foreign key mapping information used when buildingColumnMetadata.
Notable behaviors
DataTableCreatorreads column schema fromSqlDataReader.GetSchemaTable()and populatesColumnMetadatafields such asColumnName,DataType,MaxLength, and (when implemented)IsNullable. The project also supports loading primary key information and populatingDataTable.PrimaryKey.- The adapter supports a parameter dictionary passed into
FillAsync, e.g.IDictionary<string, object?>to map command parameters.
Integration notes
- The adapter uses
Microsoft.Data.SqlClient. Ensure your application has the package referenced. FillAsyncsupports parameter dictionaries; keys should match the parameter names used in the SQL (including the@if you use it in your code).DataTableCreatorexposes an event (LoadDataTableKeysInformationRequest) so callers can supply primary key and foreign-key lookup data before columns/rows are finalized. This allows key population logic to run before rows are added.
Recommended improvements (already implemented or easy to add)
- Populate
ColumnMetadata.IsNullablefromGetSchemaTable()(AllowDBNull/IsNullable) when available. - Populate
DataTable.PrimaryKeyfrom key discovery (the adapter already provides hooks to fetch primary key information — call these before finalizing theDataTable). - Ensure the adapter infers nullability conservatively when the provider schema does not include it (for example, treat CLR non-nullable value types as non-nullable).
Where to find it in the solution
- Project folder:
PocoDataSet.SqlServerDataAdapter - Key files:
SqlDataAdapter.cs— public adapter APIDataTableCreator/*.cs— schema / row building helpersForeignKeyData.cs— FK metadata model
PocoDataSet.EfCoreBridge
Optional bridge between Entity Framework Core and PocoDataSet. It provides convenience helpers to materialize EF Core queries (sync/async) and project results into a PocoDataSetIDataTable.Purpose
- Convert
IQueryable<TEntity>results intoIDataTableusing explicit schema (List<IColumnMetadata>). - Support both synchronous and asynchronous query execution (
ToDataTable(...)/ToDataTableAsync(...)). - Keep UI layers dataset-driven while allowing EF Core as the persistence/query model.
Key types / extension methods
QueryableExtensions.ToDataTable(...)QueryableExtensions.ToDataTableAsync(...)
Notable behaviors
- Schema is provided explicitly via
listOfColumnMetadatato keep deterministic columns and avoid accidentally including navigation/complex properties. - Internally, the bridge composes existing PocoDataSet extensions:
IDataSet.PocoListToDataTable<T>(...)IDataTable.CopyFromPocoList<T>(...)IDataRow.CopyFromPoco(...)/IDataRow.CopyToPoco(...)IDataRow.ToPoco<T>()
Where to find it in the solution
- Project folder:
PocoDataSet.EfCoreBridge
- Convert
Getting started
1. Add the projects to your solution
If you cloned this repo standalone:
- Open
PocoDataSetSolution.slnin Visual Studio ordotnetCLI. - Or reference the projects from your own solution:
<ItemGroup> <ProjectReference Include="..\PocoDataSet.IData\PocoDataSet.IData.csproj" /> <ProjectReference Include="..\PocoDataSet.Data\PocoDataSet.Data.csproj" /> <ProjectReference Include="..\PocoDataSet.Extensions\PocoDataSet.Extensions.csproj" /> <ProjectReference Include="..\PocoDataSet.IObservableData\PocoDataSet.IObservableData.csproj" /> <ProjectReference Include="..\PocoDataSet.ObservableData\PocoDataSet.ObservableData.csproj" /> <ProjectReference Include="..\PocoDataSet.ObservableExtensions\PocoDataSet.ObservableExtensions.csproj" /> <ProjectReference Include="..\PocoDataSet.Serializer\PocoDataSet.Serializer.csproj" /> <ProjectReference Include="..\PocoDataSet.SqlServerDataAdapter\PocoDataSet.SqlServerDataAdapter.csproj" /> </ItemGroup>
Observable layer (UI reactivity)
If you are building a UI (Blazor/WPF/WinUI/etc.) and want event-driven updates, use the observable layer:
- Contracts:
PocoDataSet.IObservableData - Implementations:
PocoDataSet.ObservableData - Helpers:
PocoDataSet.ObservableExtensions
Recommended usage pattern (one view per control instance):
- Call
ObservableDataSet.GetObservableDataView(tableName, filter, caseSensitive, sort, requestorName) - Ensure
requestorNameis unique per control instance (the observable layer enforces this) - Dispose the view (or remove the table) to unsubscribe event handlers deterministically
License
This project is licensed under the MIT License.
See the LICENSE file for details.
Installation
The easiest way to get started is to install the meta-package:
dotnet add package PocoDataSet
This will bring in: PocoDataSet.IData PocoDataSet.Data PocoDataSet.Extensions PocoDataSet.Serializer PocoDataSet.SqlServerDataAdapter
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Microsoft.Data.SqlClient (>= 6.1.0)
- Microsoft.EntityFrameworkCore (>= 9.0.6)
- Microsoft.EntityFrameworkCore.SqlServer (>= 9.0.6)
- PocoDataSet.Data (>= 1.0.32)
- PocoDataSet.Extensions (>= 1.0.32)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on PocoDataSet.SqlServerDataAdapter:
| Package | Downloads |
|---|---|
|
PocoDataSet
Meta-package that brings in all POCO DataSet components. The POCO DataSet documentation is published in the "POCO DataSet" section of businessprocessprogramming.net website. Technical support: support@businessprocessprogramming.net |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.5 | 86 | 5/30/2026 |
| 2.0.4 | 89 | 5/30/2026 |
| 2.0.3 | 106 | 5/23/2026 |
| 2.0.2 | 102 | 5/3/2026 |
| 2.0.1 | 105 | 4/9/2026 |
| 2.0.0 | 109 | 3/7/2026 |
| 1.0.33 | 103 | 3/1/2026 |
| 1.0.32 | 103 | 2/28/2026 |
| 1.0.31 | 107 | 2/23/2026 |
| 1.0.30 | 104 | 2/22/2026 |
| 1.0.29 | 101 | 2/22/2026 |
| 1.0.28 | 110 | 2/20/2026 |
| 1.0.27 | 107 | 2/10/2026 |
| 1.0.25 | 108 | 2/6/2026 |
| 1.0.24 | 110 | 2/2/2026 |
| 1.0.23 | 115 | 1/27/2026 |
| 1.0.22 | 111 | 1/24/2026 |
| 1.0.21 | 113 | 1/20/2026 |
| 1.0.20 | 116 | 1/10/2026 |
| 1.0.19 | 117 | 1/9/2026 |