Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

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

Closed
bjth opened this issue Aug 10, 2016 · 4 comments
Closed

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

bjth opened this issue Aug 10, 2016 · 4 comments
Labels
Milestone

Comments

@bjth
Copy link

bjth commented Aug 10, 2016

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?

@cpisto
Copy link

cpisto commented Aug 11, 2016

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?

@henkmollema
Copy link
Owner

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

@bjth
Copy link
Author

bjth commented Aug 19, 2016

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

@henkmollema henkmollema mentioned this issue Aug 22, 2017
3 tasks
@henkmollema henkmollema modified the milestone: v2.0 Aug 22, 2017
@henkmollema henkmollema modified the milestones: v2.0, v1.7.0 Nov 16, 2018
@henkmollema
Copy link
Owner

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants