I've been testing the new features in .Net 4 and have run into a strange problem. I'm calling a stored procedure in SQL 2008 that returns a query so I've added a Function Import creating a new Complex Type (called sp_Result) of the result set. When I execute it the call to the stored procedure will work intermittently on the first pass, but then always times out on the second pass. The exception is a System.Data.SqlClient.SqlException Timeout expired message. The SP query is simple and executes in milliseconds normally so it seems like the call is never making it to the database. I'm at a loss, is there something additional that needs to be done when using stored procs?
List<sp_Result> myList = new List<sp_Result>();
using (MySQLDatabaseEntities entities = new MySQLDatabaseEntities())
{
var myQueryResult = (from c in entities.TABLE1
where c.CREATEDDATE == System.DateTime.Today
select new { c.FIELD1, c.FIELD2 }).Distinct();
foreach (var item in myQueryResult)
{
foreach (sp_Result myResult in entities.StoredProc(item.FIELD1, item.FIELD2))
{
myList.Add(myResult);
}
}
}