标签: dapper

Dapper 无法正确映射使用 LEFT JOIN (splitOn) 选择的行

我有两个模型供应商和用户。每个用户可能只有一个供应商,也可能没有。供应商可能有多个用户。

楷模:

public class AppUser
{
    public int Id { get; set; }
    public string? FullName { get; set; }
    public string? Position { get; set; }
    public int StatusId { get; set; }
    public int VendorId { get; set; }
}


public class Vendor
{
    public int VendorId { get; set; }
    public string? VendorCode { get; set; }
    public string? VendorName { get; set; }
    public int StatusId { get; set; }
    public List<AppUser> CompanyUsers { get; set; …
Run Code Online (Sandbox Code Playgroud)

.net c# dapper .net-core

0
推荐指数
1
解决办法
910
查看次数

Dapper.net使用查询进入字典

我的sql是:

select (select count(*) from TblRMember where sex=1) male,
 (select count(*) from TblRMember where sex=2) female,
 (select count(*) from TblRMember where sex=0) unkown
Run Code Online (Sandbox Code Playgroud)

我希望Dapper.Net像这样返回一个Dictinary:

Keys:male,female,nukown
Value:10,30,50
Run Code Online (Sandbox Code Playgroud)

我看到如何使用Dapper Dot Net从数据库结果映射到Dictionary对象?,但那不行!

如何使用ToDictionary或其他方式实现我想要的

var myDictionary = sqlConnection.Query(strSql).ToDictionary(??);
Run Code Online (Sandbox Code Playgroud)

谢谢!

c# dapper

-1
推荐指数
1
解决办法
5606
查看次数

如何像使用DataGridView.DataSource一样使用List <Dynamic>?

我正在尝试将a绑定List<dynamic>到DataGridView DataSource属性.虽然编译时没有错误,但也没有显示任何列.

如果我预先创建列,我会显示要显示的行,但它们中没有数据.

简单地说,如何List<dynamic>在DataGridView中正确使用对象?

.net c# datagridview dapper

-1
推荐指数
1
解决办法
2813
查看次数

处理对象哪个更好?

在这种方法的情况下:

public void Delete(int id)
{
    using (var connection = GetOpenConnection())
    {
        connection.Execute($"DELETE FROM MyTable WHERE Id = {id}");
    }
}
Run Code Online (Sandbox Code Playgroud)

要不就:

GetOpenConnection().Execute($"DELETE FROM MyTable WHERE Id = {id}");
Run Code Online (Sandbox Code Playgroud)

我想知道第二个是否是减轻维护和简化的最佳选择.

c# garbage-collection using dapper

-1
推荐指数
1
解决办法
83
查看次数

Does Dapper support custom types on stored procedure parameters?

If I have a custom type (in my case, a Date class), is it possible to have Dapper automatically handle the type conversions when setting up stored procedure parameters? At the moment, I have to do this:

public void Execute(Date value)
{
    var parameters = new DynamicParameters();
    parameters.Add("MyDate", Date.ToDateTime(), DbType.Date);
    Execute("dbo.InsertDate", parameters, CommandType.StoredProcedure);
}
Run Code Online (Sandbox Code Playgroud)

Do I really have to convert it to a more recognised system type? I was hoping that Dapper's TypeHandler code would work, but it seems to …

c# dapper

-1
推荐指数
1
解决办法
77
查看次数

标签 统计

c# ×5

dapper ×5

.net ×2

.net-core ×1

datagridview ×1

garbage-collection ×1

using ×1