1
Vote

Support for Parallel ?

description

I tried the code below having some exception "binding parameter invalid" 4 times over 1000
Any idea ?

System.ArgumentException: Liaison de paramètre non valide
Nom du paramètre : ::sql_date
à FluentData.ExecuteQueryHandler.HandleQueryException(Exception exception)
à FluentData.ExecuteQueryHandler.ExecuteQuery(Boolean useReader, Action action)
à FluentData.DbCommand.Execute()
à CA_FluentD.Program.insert_obj(IDbContext context, Int32 index) dans d:_PROJETS\MICROORM\CA_FluentD\Program.cs:ligne 49



using (IDbContext context = Context())
                {
                    //for( int cpt = 0; cpt<1000; cpt++)
                    //insert_obj(context, cpt);
                    Parallel.For(0, 1001, new ParallelOptions() { MaxDegreeOfParallelism = 10 }, p =>
                    {
                        insert_obj(context, p);
                    });
                }
static bool insert_obj(IDbContext context, int index)
    {
            try
            {
                    return context.Sql(@"INSERT INTO LOG 
                    ( LOGLEVEL , LOGDATE, USERNAME, APPLICATION, HOST, MESSAGE, STACKTRACE)
                    VALUES (  :sql_level,  :sql_date,  :sql_user,  :sql_app,  :sql_host,  :sql_message,  :sql_stack)")
                                                    .Parameter(":sql_level", "TEST", DataTypes.String)
                                                    .Parameter(":sql_date", DateTime.Now)
                                                    .Parameter(":sql_user", "TEST" + index)
                                                    .Parameter(":sql_app", "CA_FluentD" + index)
                                                    .Parameter(":sql_host", "c55084" + index)
                                                    .Parameter(":sql_message", "Message " + index)
                                                    .Parameter(":sql_stack", "")
                                                    .Execute() > 0;
            }
            catch (Exception err)
            {
                LogHelper.Manage("CA_FluentD", err);
                return false;
            }
    }

comments