DapperLib / DapperLib/Dapper

Materializing objects inheriting from DynamicObject

Open
#406 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

A few days ago I found myself in the need to use Query<T> with an object inheriting from DynamicObject.

Currently, as per @mgravell's kind answer, this is not supported. He suggested I open an issue so you guys can take a look.

All references to my use case are detailed in my StackOverflow question linked above, along with a brief and by no means complete exchange of opinions as to how this could be handled.

Basically, the constructor for DefaultTypeMap (going from memory here, the names could be wrong) is quite PropertyInfo-centric, which would probably need to to be changed to also look at T and whether it implements IDynamicMetaObjectProvider.

The suggestions were to support DynamicObject-derived objects both for materializing and as parameters, hence:

  • probing for IDynamicMetaObjectProvider
  • allowing use of such objects as parameters, with the limitation that they have to provide an override for GetDynamicMemberNames()

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 the DefaultTypeMap constructor and its PropertyInfo-centric lookup, then trace the materialization and parameter paths for types implementing IDynamicMetaObjectProvider. Done means DynamicObject-derived types are supported for materialization and parameters, with parameter objects requiring GetDynamicMemberNames() as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend-api-design, databases
Issue type
Feature
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.