标签: slapper.automapper

Slapper.Automapper 与 Dapper.net 使用 Guid Id

我需要使用 Dapper.net 将一对多扁平化 SQL 查询映射到嵌套对象中。

Slapper.Automapper 似乎是做到这一点的好方法;正如这个问题的答案中所详细说明的:

如何在 Dapper.Net 中编写一对多查询?

我使用 Guid 得到的错误数据集: 在此输入图像描述

public string MrFlibble3()
{
    using (var connection = new SqlConnection(Constr))
    {
        Slapper.AutoMapper.Cache.ClearInstanceCache();

        const string sql = @"SELECT tc.[IDG] as ContactIdg
                                ,tc.[ContactName] as ContactName
                                ,tp.[Idg] AS TestPhones_PhoneIdg
                                ,tp.[ContactIdg] AS TestPhones_ContactIdg
                                ,tp.[Number] AS TestPhones_Number
                                FROM TestContact tc
                                INNER JOIN TestPhone tp ON tc.Idg = tp.ContactIdg";

        // Step 1: Use Dapper to return the  flat result as a Dynamic.
        dynamic test = connection.Query<dynamic>(sql);

        // Step 2: Use Slapper.Automapper for mapping …
Run Code Online (Sandbox Code Playgroud)

dapper slapper.automapper

4
推荐指数
1
解决办法
2896
查看次数

标签 统计

dapper ×1

slapper.automapper ×1