Skip to content

Map to Dictionary Support #53

@nareshkumar66675

Description

@nareshkumar66675

I am trying to map Dapper Data to an Object. But am facing problem while mapping to Dictionary objects.

The Requirement is to map a Data Row to an Object.
Data Row
1 | Key1 | Value1
1 | Key2 | Value2

Expected Values
Id -> 1
Data -> {{"Key1","Value1" }, { "Key2","Value2"}}

Map Code:

            IDictionary<string, object> entity = new Dictionary<string, object>();
            entity.Add("Id", "1");
            entity.Add("Data_Key", new List<string>() { "Key1", "Key2" });
            entity.Add("Data_Value", new List<string>() { "Value1", "Value2" });
            var result=Slapper.AutoMapper.Map<TestEntity>(entity);

Entity Object

    public class TestEntity
    {
        public int Id { get; set; }
        public Dictionary<string,string> Data { get; set; }
    }

Is there a way to achieve this ??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions