- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
class Person
{
Address Addr { get; set; }
int Age { get; set; }
}
class Address
{
string StreetName { get; set; }
County Cnty { get; set; }
}
class County
{
string CntyName;
string CntyCode;
}
Create Procedure SpGetAllPersons
As
Select CntyName, CntyCode, StreetName, Age from Persons
DBConn.Query<County, Address , Person, Person>
(DomainConstants.SpGetAllPersons,
(cnty, address, person) =>
{
address.Cnty = cnty;
person.Addr = address;
return person;
},
commandType: CommandType.StoredProcedure,
splitOn: "StreetName, Age").ToList();
var sql =
@"select
1 as PersonId, 'bob' as Name,
2 as AddressId, 'abc street' as Name, 1 as PersonId,
3 as Id, 'fred' as Name
";
var personWithAddress = connection.Query<Person, Address, Extra, Tuple<Person, Address, Extra>>
(sql, (p, a, e) => Tuple.Create(p, a, e), splitOn: "AddressId,Id").First();
最佳答案
感谢马克和鲍勃跳上它。我能够以其他方式解决问题:
DBConn.Query(DomainConstants.SpGetAllPersons, commandType: CommandType.StoredProcedure)
.Select(x => new Person
{
Addr = new Address
{
Cnty = new County
{
CntyName = x.CntyName,
CntyCode = x.CntyCode
},
StreetName = x.StreetName
},
Age = x.Age
}).ToList();
关于.net - 嵌套多映射的 Dapper 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6855013/
有谁知道或有如何使用的链接https://github.com/henkmollema/Dapper-FluentMap在我的 Dapper CRUD 中?现在我正在使用 Dapper.Contrib
我正在寻找一种方法来仅更新 Dapper 中的设置属性。即仅当实体的属性不为空时才更新实体的属性。 我正在用一种相当粗糙的方法解决同样的问题,如下所示,但我相信应该有一种更简洁的方法来做到这一点。
方案: 我的模型中有一个字符串属性,其中包含MultiSelectList @Html.ListBox的ID。如果选择两个列表项,则我的属性值将类似于0100,0500。 问题: Dapper whe
我们正在使用 Dapper 进行一些数据访问事件,并使用标准推荐方法连接到数据库,如下所示: public static Func ConnectionFactory = () => new SqlC
是否可以通过表名 作为 Dapper Query 命令的参数?我不是在寻找 SQL 表定义的函数或 SQL 表变量。我想在 C# 中定义表名并将其传递给 Dapper。这是我的代码,执行时返回错误 M
我在dapper中尝试对包含NULL的列进行拆分时遇到MultiMaps问题。 Dapper似乎不实例化对象,并且我的映射函数接收null而不是对象。 这是我的新测试: class Produ
我似乎找不到我的问题的文档或示例(现在已经搜索了一段时间)。我认为我的问题很简单,所以这里是。 我有两张 table 。我的主表称为 Persons,辅助表是 PersonEntries。对于 Per
我的代码有点问题,我想让 dapper 很好地使用它。 当我说我的代码是继承的,所以这不是我的设计。 我正在尝试替换 Entity Framework,因为对数据库的调用效率不高,所以我想更好地控制生
我已经开始玩 Dapper.Net,到目前为止我真的很喜欢它 - 然而,我遇到了一个问题。 假设我有一个 POCO 类: public class Person { public string
我已经开始玩 Dapper.Net,到目前为止我真的很喜欢它 - 然而,我遇到了一个问题。 假设我有一个 POCO 类: public class Person { public string
我知道这是一种错误的做法,但我正在处理具有 NULLS 的遗留代码库,当它表示空字符串时,反之亦然。 我无法立即看到它是如何可能的,但是当从数据库映射回来时,是否有可能获取(或修改 dapper 以便
我正在尝试选择一个包含 2 个整数列的列表,将结果映射到一个元组。举个例子: return connection.Query>("select id1, id2 from sometable").To
我有一个存储过程,它有一个没有默认值的参数,但它可以为空。但我不知道如何使用 Dapper 传递 null。我可以在 ADO 中做得很好。 connection.Execute("spLMS_Upda
我决定使用 Dapper.net,因为它似乎只做我想做的事情:映射,我不需要任何花哨的东西,我只是厌倦了处理我的数据读取器和我的对象之间的映射。 我的问题: 假设我有这些类(class): class
我在从 Dapper 查询返回单个对象时遇到问题。我有一个简单的查询,我想从返回的集合中获取第一个对象。我错过了什么? using (SqlConnection sqlConnection = new
假设我的实体是 public class AppUser { string Id { get; set; } string Name { get; set; } } 看起来默认情况下
我在Dapper官方文档中看到了QueryMultiple,如下所示,很方便! var sql = @" select * from Customers where CustomerId =
我正在使用 Dapper 查询包含 XML 字段的表: CREATE TABLE Workflow ( Guid uniqueidentifier not null, State xm
我有一个来自Dapper查询的动态结果,其中包含如下记录: {DapperRow, billing_currency_code = 'USD', count(*) = '6'} 我可以使用rowVar
我正在使用 Dapper 扩展,但我的数据库中有多个架构名称。 我在下面的链接中找到了答案,但它假设我只有一个模式名称,这不是我的情况。 Dapper Extensions Change Schema
我是一名优秀的程序员,十分优秀!