DapperLib / DapperAOT

Build time tools in the flavor of Dapper
Other
349 stars 19 forks source link

How to use with multimapper #114

Open ADringer opened 4 months ago

ADringer commented 4 months ago

I have the following command:

var unitGrouping = new Dictionary<string, ValueTuple<HashSet<IndoorRecord>, HashSet<OutdoorRecord>>>();

_ = await mySqlConnection.QueryAsync<IndoorRecord, OutdoorRecord, bool>(@"
        select BIN_TO_UUID(iu.id) as id, iu.model, iu.serial, iu.name, iu.type, iu.interface_mac, iu.interface_serial, iu.interface_model, BIN_TO_UUID(iu.system_id) as system_id, 
        BIN_TO_UUID(ou.id) as id, ou.model, ou.serial, BIN_TO_UUID(ou.system_id) as system_id                    
        from building b 
        inner join indoor_unit iu on b.id = iu.building_id 
        left join outdoor_unit ou ON iu.system_id = ou.system_id 
        where b.id = UUID_TO_BIN(@buildingId)",
    (iu, ou) =>
    {
        if (!unitGrouping.ContainsKey(iu.SystemId))
            unitGrouping.Add(iu.SystemId, ([], []));

        unitGrouping[iu.SystemId].Item1.Add(iu);

        if (ou != null)
            unitGrouping[iu.SystemId].Item2.Add(ou);

        return true;
    },
    new { buildingId });

This generates the expected message DAP001 as the method is on SqlMapper which isn't supported yet.

But, is there a way of changing the code so I can use the multimapper like above with AOT, or is this just something not possible at this time? I saw in a different issue that suggested to not use the extension method but that didn't seem to make any difference.

Thanks