Skip to content

Does not appear to work with QueryMultiple and .Read<> #43

Closed

Description

@bjth

When using Dapper QueryMultiple, it appears the mapped columns are not working.

In my case QueryMultiple returns 3 tables.

var ds = con.QueryMultiple("uspSELNodes", p, commandType: CommandType.StoredProcedure);
var rows = ds.Read().ToDictionary(v => v.RowNo); //Returns a dynamic dictionary
var total = ds.Read<int>().First(); //Returns table 2 that contains just an int for a total
var columns = ds.Read<DynamicTable.Column>(); // Does not seem to map properly.

Class is as below :

 public class Column : IDynamicTableColumn
        {
            public string Prefix { get; set; }
            public string Name { get; set; }
            public string DisplayName { get; set; }
            public int Order { get; set; }
            public bool Orderable { get; set; }
            public bool Filterable { get; set; }
            public int Width { get; set; }
            public string ResourceName { get; set; }
        }

Mapping :

private class DynamicColumnMap : EntityMap<DynamicTable.Column>
        {
            public DynamicColumnMap()
            {
                Map(x => x.Prefix).ToColumn("column_prefix");
                Map(x => x.Name).ToColumn("column_name");
                Map(x => x.Order).ToColumn("display_order");
                Map(x => x.Orderable).ToColumn("can_be_ordered");
                Map(x => x.Filterable).ToColumn("can_be_filtered");
                Map(x => x.Width).ToColumn("column_width_in_pixels");                
            }
        }

Config :

FluentMapper.Initialize(config =>
            {
                config.AddMap(new DynamicColumnMap());
                config.AddConvention<LowerCaseConvention>        ().ForEntitiesInAssembly(typeof(Configuration).Assembly);
            });

The columns that match name for name for example DisplayName all get their correct values from Dapper, the mapped columns appear to be getting the defaults for their type, strings empty, bools false and ints 0.

Am I initializing this correctly?

Activity

  1. cpisto commented on Aug 11, 2016

    @cpisto

    I'm seeing something similar with multi-mapping as well. Could be related to #42

    Out of curiosity, if you try with Dapper.FluentMap 1.4.1 instead of 1.5.* does it work?

  2. henkmollema commented on Aug 16, 2016

    @henkmollema
    Collaborator

    @Darkwind791 as @cpisto mentiond, would you mind testin this against v1.4.1?

  3. bjth commented on Aug 19, 2016

    @bjth
    Author

    Hey @henkmollema, sorry only just got around trying this, @cpisto 4.1 is working correctly. Hope that helps.

  4. modified the milestone: v2.0 on Aug 22, 2017
  5. modified the milestones: v2.0, v1.7.0 on Nov 16, 2018
  6. henkmollema commented on Nov 16, 2018

    @henkmollema
    Collaborator

    This have been fixed for applications targeting full .NET (e.g. 4.5 or higher) and .NET Core 2.0 and 2.1 in version 1.7.0: NuGet and release notes.

    Please re-open or create a new issue if the problem persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址