I have a code like this, how I can do to set the "CommnadTimeout"?
var database = EnterpriseLibraryContainer.Current.GetInstance<Database>();
var sqlGetAllPersons = @"select * from Person.Person";
var personMapper = MapBuilder<Person>.MapAllProperties().Build();
// create an accessor (DataAccessor)
var personAccessor = database.CreateSqlStringAccessor<Person>(sqlGetAllPersons, personMapper);
// execute the accessor (IEnumerable<Person>)
var profiles = personAccessor.Execute();
(code from EntLib 5.0 DAAB MapBuilder maps DBNull to null)
thanks
Although I like little this solution, I was able to fix it this way:
public class ParameterMapperWithCommandTimeout : IParameterMapper
{
public int CommandTimeout { get; set; }
public void AssignParameters(DbCommand command, object[] parameterValues)
{
command.CommandTimeout = this.CommandTimeout;
}
}
applied to the previous example:
var database = EnterpriseLibraryContainer.Current.GetInstance<Database>();
var sqlGetAllPersons = @"select * from Person.Person";
var personMapper = MapBuilder<Person>.MapAllProperties().Build();
var parameterMapper = new ParameterMapperWithCommandTimeout { CommandTimeout = MyTimeOut };
// create an accessor (DataAccessor)
var personAccessor = database.CreateSqlStringAccessor<Person>(sqlGetAllPersons, parameterMapper, personMapper);
// execute the accessor (IEnumerable<Person>)
var profiles = personAccessor.Execute();