title: Database name is not allowed with a table-valued parameter
body: <p>I am getting following error when I call the <code>Select</code> function:</p>
  
  <blockquote>
    <p>The incoming tabular data stream (TDS) remote procedure call (RPC)
    protocol stream is incorrect. Table-valued parameter 3
    ("@SearchTableVar"), row 0, column 0: Data type 0xF3 (user-defined
    table type) has a non-zero length database name specified.  Database
    name is not allowed with a table-valued parameter, only schema name
    and type name are valid.</p>
  </blockquote>
  
  <p><strong>C# code</strong></p>
  
  <pre><code>//DTO
  public class SP_SearchEntity_Result
  {
      public string ID { get; set; }
      public string NAME { get; set; }
  }
  
  //Businesslogic
  public IQueryable Select(int PageIndex, int PageSize, List&lt;KeyValuePair&lt;string, string&gt;&gt; SearchBy, List&lt;KeyValuePair&lt;string, System.Data.SqlClient.SortOrder&gt;&gt; SortBy)
  {
      SqlDatabase obj = (SqlDatabase)DatabaseFactory.CreateDatabase();//System.Configuration.ConfigurationManager.ConnectionStrings["MySqlServer"].ConnectionString
      return obj.ExecuteSprocAccessor&lt;SP_SearchEntity_Result&gt;("SP_SearchEntity", PageIndex, PageSize, SearchBy.ToDataTable(), SortBy.ToDataTable()).AsQueryable&lt;SP_SearchEntity_Result&gt;();
  }
  
  //Extension methods
  public static DataTable ToDataTable(this List&lt;KeyValuePair&lt;string, string&gt;&gt; source)
  {
      DataTable dataTable = new DataTable("Test");
      dataTable.Columns.Add("KEY",typeof(System.String));
      dataTable.Columns.Add("VALUE", typeof(System.String));
  
      foreach (KeyValuePair&lt;string, string&gt; data in source)
      {
          var dr = dataTable.NewRow();
          dr["KEY"] = data.Key;
          dr["VALUE"] = data.Value;
          dataTable.Rows.Add(dr);
      }
  
      return dataTable;
  }
  
  public static DataTable ToDataTable(this List&lt;KeyValuePair&lt;string, System.Data.SqlClient.SortOrder&gt;&gt; source)
  {
      DataTable dataTable = new DataTable("Test");
      dataTable.Columns.Add("KEY", typeof(System.String));
      dataTable.Columns.Add("VALUE", typeof(System.String));
  
      foreach (KeyValuePair&lt;string, System.Data.SqlClient.SortOrder&gt; data in source)
      {
          var dr = dataTable.NewRow();
          dr["KEY"] = data.Key;
          dr["VALUE"] = data.Value == System.Data.SqlClient.SortOrder.Ascending ? "ASC" : "DESC";
          dataTable.Rows.Add(dr);
      }
  
      return dataTable;
  }
  </code></pre>
  
  <p><br/>
  <br/>
  The stored procedure returns two tables in result</p>
  
  <p><strong>SQL proc definition</strong></p>
  
  <pre><code>CREATE TYPE KeyValueTableVariable AS TABLE
  (
      [KEY] NVARCHAR(800),
      [VALUE] NVARCHAR(800)
  )
  GO
  CREATE PROCEDURE SP_SearchEntity
  @PageIndex INT=NULL,      
  @PageSize INT=NULL,     
  @SearchTableVar dbo.KeyValueTableVariable READONLY,
  @SortTableVar dbo.KeyValueTableVariable READONLY 
  AS
  BEGIN
      /*Bla bla bla*/
      SELECT '1' as [ID], 'Nitin' as [NAME]
      SELECT '1' as [COUNT]
  END
  </code></pre>