Batching ExecuteSqlCommand statements on a code-first DbContext RRS feed

  • Question

  • Hi there, I'm calling ExecuteSqlCommand several thousands times per minute and each one is a round-trip to the database.  The command itself calls a stored procedure and the parameters vary from INTs to NVARCHARS to "Structured" table-value parameters. When I look at the SQL commands generated by Entity Framework via SQL Profiler quite a sizeable chunk of data is being sent to the DB.

    Given that there is no return value from the SP, it's very much "fire and forget", I'd like to try to batch up the SQL commands and send, say, a batch of 10 at once.  Is this possible using Entity Framework?  Is there a way to get Entity Framework to return me the full SQL command per call and then I could concatenate the SQL myself and call ExecuteSqlCommand myself?

    Many thanks for your help


    Sunday, October 28, 2012 10:44 AM