DapperLib / DapperLib/Dapper

Proposal: simplify TVP creation

Open
#807 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

The idea is to provide ability to auto-convert IEnumerable<POCO> to TVP (IEnumerable<SqlDataRecord>)
To simplify TVP creation i propose to provide ability to fetch and cache TVP metadata from DB.

declare @a dbo.table_type_name_here
select * from @a

this lightweight query will produce empty resultset, it's possible to cache and use this metadata (dataReader.GetSchemaTable) to create POCO->TVP mapping.

somehow:

CREATE TYPE [dbo].[arrayOf_int] AS TABLE([e] [int] NULL)
var builder = cnn.TvpBuilder("dbo.arrayOf_int") //<-fetch/cache metadata at this point
...
cnn.Query<int>("select * from @tvp",
    new {tvp=builder.make(Enumerable.Range(1,10).Select(e=>new{e}))}) //<- map at this point

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named. Start by locating Dapper's existing table-valued parameter handling and review how ADO.NET schema metadata can be obtained with GetSchemaTable; done would require an agreed API that caches TVP metadata and converts IEnumerable values for the demonstrated query pattern.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.