C# Dapper problems with IN statement using string array
<p>I have an string array (query.Tags) for filter a list of values and each time, procces just take the first value of string array during the query execution.
I tried several combinations but nothing changed. Of course, I tested all of these SQL statements in SQL SERVER View.</p>

<p><strong>Can you tell me what I doing wrong?</strong></p>

<pre><code>public IEnumerable&lt;ActorDto&gt; SearchMembersInLists(ListMembersQuery query)
  {
    IEnumerable&lt;ActorDto&gt; result = null;
    var sql = @"select DISTINCT t.ActorId,
                            a.Id, a.TypeId, a.Name, a.Identifier
                            FROM [ActorTag] t 
                            INNER JOIN [Actor] a ON t.ActorId = a.Id
                            where t.Name IN @tags
     ";
    using (var cnx = DbConnectionFactory.GetDefault().GetConnection())
       {
           cnx.Open();
           var query_result = cnx.QueryMultiple(sql, new { query.Tags});                
           result = query_result.Read&lt;ActorDto&gt;();               
        }           

       return result;        
    }
</code></pre>

<p><strong>the original code is this, i just tried to simplify as I could</strong></p>

<pre><code>public IEnumerable&lt;ActorDto&gt; SearchMembersInLists(ListMembersQuery query)
        {
            IEnumerable&lt;ActorDto&gt; result = null;
            var sql = @"
                SELECT DISTINCT a.Id, a.TypeId, a.Name, a.Identifier,a.Description, a.Email, a.PictureUrl, a.DisplayName --Actor
                  FROM [RoleMember] lm
                  INNER JOIN [Actor] a ON lm.ActorId = a.Id
                  WHERE {tag_filter} {lists_filter}
                  ORDER BY a.DisplayName DESC OFFSET @pageIndex ROWS FETCH NEXT @pageSize ROWS ONLY
            ";


            bool has_tags = true;
            bool has_lists = true;
            if (query.Tags != null &amp;&amp; query.Tags.Any())
            {
                sql = sql.Replace("{tag_filter}", "a.Id IN (SELECT t.ActorId FROM [ActorTag] t WHERE t.Name IN @tags)");
                has_tags = true;
            }
            else
            {
                sql = sql.Replace("{tag_filter}", "");
                has_tags = false;
            }

            if (query.Lists != null &amp;&amp; query.Lists.Any())
            {
                if (has_tags)
                {
                    sql = sql.Replace("{lists_filter}", "AND lm.RoleId IN @lists");
                }
                else
                {
                    sql = sql.Replace("{lists_filter}", "lm.RoleId IN @lists");
                }
                has_lists = true;
            }
            else
            {
                sql = sql.Replace("{lists_filter}", "");
                has_lists = false;
            }

            if (!has_tags &amp;&amp; !has_lists){
                sql = sql.Replace("WHERE", "");
            }

            var values = new
            {
                lists = query.Lists,
                tags = query.Tags,               
                pageIndex = query.PageIndex * query.PageSizeOrDefault,
                pageSize = query.PageSizeOrDefault
            };

            using (var cnx = DbConnectionFactory.GetDefault().GetConnection())
            {
                cnx.Open();                 
                result = cnx.Query&lt;ActorDto&gt;(sql, values);             
            }           

            return result;        
        }
</code></pre>