none
DbType.Structured not available

    Question

  •  

    I am trying to use DbType.Structure to pass in a readonly table . This feature came in sql server 2008 and therefore ado.net has support for that with SqlDbType.Structured but when i create an instance of my entity parameter there is no such thing as DbType.Structured.

    var param = new EntityParameter("tableparameter", System.Data.DbType.?); // structured not there.

     

    I am not doing anything complicated. very simple stuff have a stored procedure which takes in a bunch of values as a table and does bulk insert using stored procedure. declared teh stored procedure in ssdl, imported that into the conceptual model and fixed my mapping and created a partial method on objectcontext to grab the the entityconnection and doing it manually. Here is some incomplete code

    private void ExecuteNonQuery(string functionname, DbParameter[] parameters)

    {

    DbCommand cmd = this.Connection.CreateCommand();

    cmd.CommandType = System.Data.CommandType.StoredProcedure;

    cmd.Parameters.AddRange(parameters);

    cmd.CommandText = this.DefaultContainerName + "." + functionname;

    if (cmd.Connection.State == System.Data.ConnectionState.Closed)

    {

    cmd.Connection.Open();

    }

    cmd.ExecuteNonQuery();

    }

     

    So question is how do i do it?

     

    Thanks

    Zeeshan HIrani

    Sunday, September 14, 2008 5:28 AM

Answers

  • Table valued parameters are not supported in the Entity Framework v1. If you want to use a table as a parameter to a stored proc or query, you'll have to use the underlying store connection and the support that is provided there. This is something we are pushing to include in the next release of the EF, but unfrtunately it is not going to work right now.

     

    Jeff
    Sunday, September 14, 2008 5:42 AM
    Moderator