Binding empty list or null value to table valued parameter on a stored procedure (.NET)

前端 未结 4 1380
北海茫月
北海茫月 2021-02-01 00:09

I have created a stored procedure that takes a table valued parameter that is a table with a single column of type int. The idea is to simply pass a list of ids in

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-01 00:59

    I was a bit confused by what the 'not passing the parameter' statement means. What ends up working for Entity Framework ExecuteSqlCommandAsync() is this:

      new SqlParameter("yourParameterName", SqlDbType.Structured)
      {
          Direction = ParameterDirection.Input,
          TypeName = "yourUdtType",
          Value = null
      };
    

    This will pass the parameter as 'default'.

提交回复
热议问题