Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 衣冠楚楚';即使使用右边的'splitOn',也不能填充实体?_C#_Sql Server_Dapper_.net 4.6 - Fatal编程技术网

C# 衣冠楚楚';即使使用右边的'splitOn',也不能填充实体?

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

查看此简化的SQL Server查询:

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