I have following code:
ActiveModule resultObject = null;
StringBuilder sqlStringBuilder = new StringBuilder();
sqlStringBuilder.AppendLine("SELECT * FROM suite_activemodule as _module");
sqlStringBuilder.AppendLine("WHERE CityID = @CityID AND BaseModuleID = @BaseModuleID");
using (MySqlConnection connection = new MySqlConnection(ConnectionString))
{
var _resultList = connection.Query<ActiveModule>(sqlStringBuilder.ToString(), new { CityID = cityID, ModuleID = moduleID }, null, true, null, null); //<- This is were I get the error...
int listSize = _resultList.Count();
if (_resultList != null && !_resultList.Count().Equals(0))
{
resultObject = _resultList.ToList().First();
resultObject.Module = BaseModuleRepository.GetByID(resultObject.ModuleID);
}
}
The query itself works fine but as soon as I try to run the query I get the following error message:
bei MySql.Data.MySqlClient.MySqlConnection.get_ServerThread()
bei MySql.Data.MySqlClient.MySqlConnection.Abort()
bei MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
bei Dapper.SqlMapper.ExecuteReaderWithFlagsFallback(IDbCommand cmd, Boolean wasClosed, CommandBehavior behavior) in C:\projects\dapper\Dapper\SqlMapper.cs:Zeile 1053.
bei Dapper.SqlMapper.d__138`1.MoveNext() in C:\projects\dapper\Dapper\SqlMapper.cs:Zeile 1081.
bei System.Collections.Generic.List
1..ctor(IEnumerable1 collection)bei System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
bei Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable
1 commandTimeout, Nullable1 commandType) in C:\projects\dapper\Dapper\SqlMapper.cs:Zeile 723....Repository.GetByCityIDAndModuleID(Int64 cityID, Int64 moduleID)
...DeactivateModule(String moduleID)
But I am running multiple queries like this kind before and dont get this error. It don't make that much sense because nothing of the used stuff is really null.
I have already did a clean build and also a full rebuild via Visual Studio.
Does anyone know about this issue and know how to fix it?