DapperLib / DapperLib/Dapper

Is it possible to have custom object deserialization

Open
#1,624 0 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

first of all , i like dapper much more that EF.
Well , i my case , i have defined losts of Model Interfaces , for example

[TableEntity("tb_TreeNodeData", "Id")]
public interface ITreeNodeView : IPropertyChanged
{
[Field]
Guid Id { get; set; }
[Field]
Guid ParentId { get; set; }

    [Field]
    string Caption { get; set; }

    [Field]
    string Icon { get; set; }

    [Field]
    string Page { get; set; }

    [Field(HasDefaultValue = true)]
    DateTime CreateTime { get; set; }
}

then , i have a Type Generator to create a type to inherit from ITreeNodeView ,

var t = AssemblyGenerator.GenerateType();

after than , i will use dapper to Query records as List,

var list = _connection.Query(sql, param).ToList();

it throws an error : valid type owner for DynamicMethod.”
i know dapper doesn't know hot to convert dapperrow to which Type that inherited from ITreeNodeView.

and can i have my own drapper converter? or any other way ?

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 Query call and the AssemblyGenerator-generated type described in the issue. Investigate the "valid type owner for DynamicMethod" failure and how Dapper handles interface targets and deserialization. Done should be a documented or implemented way to provide a custom converter or resolve the generated concrete type.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.