C# 衣冠楚楚';即使使用右边的'splitOn',也不能填充实体?
查看此简化的SQL Server查询:C# 衣冠楚楚';即使使用右边的'splitOn',也不能填充实体?,c#,sql-server,dapper,.net-4.6,C#,Sql Server,Dapper,.net 4.6,查看此简化的SQL Server查询: set @userid2=... SELECT *, SPLIT = '', userid2 = @userid2 FROM Comments c JOIN Users u ON ... 我正在使用此部分工作的代码来执行SP: await c.QueryAsync<Comment, User, SqlInt, CommentWithSenderAn
set @userid2=...
SELECT *,
SPLIT = '',
userid2 = @userid2
FROM Comments c
JOIN Users u
ON ...
我正在使用此部分工作的代码来执行SP:
await c.QueryAsync<Comment, User, SqlInt, CommentWithSenderAndUserId2>(@"insertCommentByImageId",
(message1, user, myint) => new CommentWithSenderAndUserId2
{
User = user,
Comment = message1,
UserId2 = myint.MyIntValue
},
new {imageid = imageId, userid1 = userid1, comment = comment}, //parms
splitOn: "UserID,split", //splits
commandType: CommandType.StoredProcedure //command type
)
如您所见,它是泛型类型的一部分:
c.QueryAsync<Comment, User, SqlInt, CommentWithSenderAndUserId2>
问题
我做错了什么?如何填充myInt值 嗯,我发现了我愚蠢的错误。
问题是我创建了一个实体来保存
int
值,对吗
public class SqlInt
{
public int MyIntValue { get; set; }
}
属性的名称为MyIntValue
。如果是,我为什么这样做:
SELECT *,
SPLIT = '',
userid2 = @userid2
而不是正确的方法:
SELECT *,
SPLIT = '',
MyIntValue = @userid2 <---- change is here
选择*,
拆分=“”,
MyIntValue=@userid2
SELECT *,
SPLIT = '',
userid2 = @userid2
SELECT *,
SPLIT = '',
MyIntValue = @userid2 <---- change is here