ent lib 3.1: ExecuteScalar returning null in some situations

Topics: Data Access Application Block
Jul 20, 2007 at 5:20 PM
Hi there,

I am using the following code to retrieve the start date. The stored procedure does a SELECT startdate FROM ....

Database subscriptionDatabase = DatabaseFactory.CreateDatabase(this.ConnectionStringName);
using (DbCommand subscriptionCommand = subscriptionDatabase.GetStoredProcCommand("GetStartDate"))
subscriptionDatabase.AddInParameter(subscriptionCommand, "@UserId", DbType.Guid, userId);
subscriptionDatabase.AddInParameter(subscriptionCommand, "@SubscriptionTypeName", DbType.String, subscriptionTypeName);

object returnValue = subscriptionDatabase.ExecuteScalar(subscriptionCommand);

In my Unit tests for this code, it intermittently returns null where it should always return the start date as it is available in the db table. The strange
thing is that if do a Thread.Sleep(1000) (one second delay), it works fine! I have debugged into the EntLib 3.1 source code but
it doesnt really give me any clues.. Any ideas?

Any help would be great.