title: Nhibernate CreateSQLQuery error - SetParameterList Incorrect syntax near ','
body: <p>Error:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException: Incorrect syntax near ','</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>IQuery permissionTypes;
  
  if (regionIds != null &amp;&amp; regionIds.Count &gt; 0)
  {
      permissionTypes =  session.CreateSQLQuery(
         @"SELECT DISTINCT PT.PermissionType FROM AspNetUsers AU 
         INNER JOIN AspNetUserRoles AR ON AU.Id= AR.UserId
         INNER JOIN dbo.AspNetRoles ANR ON ANR.Id = AR.RoleId
         INNER JOIN [dbo].[tbl_RolePermissionTypeAssoc] RPT ON RPT.FK_RoleId  = AR.RoleId
         INNER JOIN tbl_PermissionType PT ON RPT.FK_permissionTypeId=PT.Id 
         WHERE AU.ID=:userId AND ANR.RegionId=:regionId")
         .SetParameter("userId", userId).SetParameterList("regionId", regionIds);
  }
  else
  {
      permissionTypes =  session.CreateSQLQuery(
         @"SELECT DISTINCT PT.PermissionType FROM AspNetUsers AU 
         INNER JOIN AspNetUserRoles AR ON AU.Id= AR.UserId
         INNER JOIN dbo.AspNetRoles ANR ON ANR.Id = AR.RoleId
         INNER JOIN [dbo].[tbl_RolePermissionTypeAssoc] RPT ON RPT.FK_RoleId  = AR.RoleId
         INNER JOIN tbl_PermissionType PT ON RPT.FK_permissionTypeId=PT.Id 
         WHERE AU.ID=:userId AND ANR.RegionId=:regionId")
         .SetParameter("userId", userId);
  }
  
  return permissionTypes.List&lt;string&gt;();
  </code></pre>
  
  <p>Generated query :</p>
  
  <pre><code>SELECT DISTINCT PT.PermissionType 
  FROM AspNetUsers AU 
  INNER JOIN AspNetUserRoles AR ON AU.Id = AR.UserId
  INNER JOIN dbo.AspNetRoles ANR ON ANR.Id = AR.RoleId
  INNER JOIN [dbo].[tbl_RolePermissionTypeAssoc] RPT ON RPT.FK_RoleId  = AR.RoleId
  INNER JOIN tbl_PermissionType PT ON RPT.FK_permissionTypeId = PT.Id 
  WHERE AU.ID = @p0 AND ANR.RegionId = @p1, @p2
  </code></pre>