I'm working on a project that uses EntitySpaces as ORM.
Below you see a simplified method of ItemCollection that loads a collection by calling a stored procedure:
public partial class ItemCollection : esItemCollection
{
public bool LoadItemsUsingSomeStoredProcedure(string aLotOfAttributes, out int totalCount)
{
// Set a lot of parameters
esParameters parameters = new esParameters();
// ...
bool result = Load(esQueryType.StoredProcedure, "ItemsStoredProcedure", parameters);
totalCount = (int) paramTotalCount.Value;
return result;
}
}
Using SQL Server Profiler I see that is results in this call to the database:
declare @p5 int
set @p5=485
exec [ItemsStoredProcedure] @Param1=4,@Param2=N'41',@Param3=N'SomeValue',@Param4=0,@TotalCount=@p5 output,@Param5=1,@Param6=25
select @p5
It takes about 200 seconds to complete.
BUT: When I run the same SQL snippet in SQL Management Studio (locally and remotely) it takes about 4~5 seconds to complete.
Any ideas why it tooks about 40x longer for the EntitySpaces call to complete than the one in the SQL client? Any ideas how this can be debugged/improved?
PS: Replacing EntitySpaces is high on my WANT-list, but as always it is really hard to convince a client to spend a month of development on refactoring a "working" program... So that option is out, atm.