Problem with TypeDescriptor with NULL columns generated from Query<dynamic>
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.
- If the Column BranchID contains at least any integral number. The Grid Cell Editor will behavior as int , object{int} from Descriptor I think.
- 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

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
- In
DapperTable.csclass I try to insert followingfieldTypesvariables

- In
SqlMapper.csfunctionGetDapperRowDeserializer()

- In
SqlMapper.DapperRow.Descriptor.csDapperRowTypeDescriptor.GetProperties()method

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

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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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