我的存储过程有一个输出参数:
@ID INT OUT
Run Code Online (Sandbox Code Playgroud)
如何使用ado.net检索此内容?
using (SqlConnection conn = new SqlConnection(...))
{
SqlCommand cmd = new SqlCommand("sproc", conn);
cmd.CommandType = CommandType.StoredProcedure;
// add parameters
conn.Open();
// *** read output parameter here, how?
conn.Close();
}
Run Code Online (Sandbox Code Playgroud) 继续运行"如果使用多映射API,请确保在下面的代码块中设置了除了Id之外的其他键的splitOn参数"错误:
var accounts = DbConnection.Query<Account, Branch, Application, Account>(
"select Accounts.*, SplitAccount = '', Branches.*, SplitBranch = '', Applications.*" +
" from Accounts" +
" join Branches" +
" on Accounts.BranchId = Branches.BranchId" +
" join Applications" +
" on Accounts.ApplicationId = Applications.ApplicationId" +
" where Accounts.AccountId <> 0",
(account, branch, application) =>
{
account.Branch = branch;
account.Application = application;
return account;
}, splitOn : "SplitAccount, SplitBranch"
).AsQueryable();
Run Code Online (Sandbox Code Playgroud)
我正在使用SplitAccount和SplitBranch for splitOn作为解决方法.
我错过了什么?
谢谢
编辑:
我已经清理了一下我的测试,下面是一个轻量级的类和一个新的查询:
public class AccountLight
{
public int …Run Code Online (Sandbox Code Playgroud) 表:
create table Documents
(Id int,
SomeText varchar(100),
CustomerId int,
CustomerName varchar(100)
)
insert into Documents (Id, SomeText, CustomerId, CustomerName)
select 1, '1', 1, 'Name1'
union all
select 2, '2', 2, 'Name2'
Run Code Online (Sandbox Code Playgroud)
类别:
public class Document
{
public int Id { get; set; }
public string SomeText { get; set; }
public Customer { get; set; }
}
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我如何与Dapper Documents一起完成所有工作 …