DapperLib / DapperLib/Dapper

Problem with TypeDescriptor with NULL columns generated from Query<dynamic>

Open
#1,372 4 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

Hello Mark,
Wish you are good, sorry for disturbing you atm.

But I found something I think its not normal behavior ofQuery<dynamic>()which you was implement SqlMapper.DapperRow.Descriptor for it before. What a great work you done.

Sometimes in database table the full column of data can be NULL, for Example "BranchID" Columns of type int.

When attach Grid DataSource with Query<T>("SELECT * FROM Table") strongly typed class. If all columns are NULL there's no problem. And Grid Editors (Cells) will behavior as integral numbers so I can't post a string inside cell of BranchID Column.

Now back to dynamic version which is good for getting data at run-time.

  1. If the Column BranchID contains at least any integral number. The Grid Cell Editor will behavior as int , object{int} from Descriptor I think.
  2. If the Column BranchID doesn't contains any integral number and no default values for that column and Column only have NULL for whole rows. It will be object of null
    And here's a problem came with Grid Cell Editor which it will behave as object not int, and now it accepts any random words "9921RPG"

I suspicious something maybe modified at following lines of code…

https://github.com/StackExchange/Dapper/blob/master/Dapper/SqlMapper.DapperRow.Descriptor.cs
a

I try to show you what make this problem. I Upload some modifications in attachments. Please can you take a shot if you have time. And can you commit or make a fix for that

  1. In DapperTable.cs class I try to insert following fieldTypes variables

1

  1. In SqlMapper.cs function GetDapperRowDeserializer()

2

  1. In SqlMapper.DapperRow.Descriptor.cs DapperRowTypeDescriptor.GetProperties() method

3

  1. Now the GridColumn Cells of type int that full row at database is null. Is accepting only numerics in-place cell editors.
    4

Again, sorry for taking some of your time. The things you made in Descriptor are really awesome. I try to upgrade any idea would or maybe someone fall in problem about it.
Thanks again :)

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

Start with DapperTable.cs, SqlMapper.cs and SqlMapper.DapperRow.Descriptor.cs, especially GetDapperRowDeserializer() and DapperRowTypeDescriptor.GetProperties(), then review the attached examples. Reproduce a dynamic query where an integer column is NULL for every row and verify that the resulting descriptor preserves the intended column type instead of exposing it as object.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.