MySql CompiledQuery

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
traufeisen
Posts: 10
Joined: Fri 03 Apr 2009 08:39

MySql CompiledQuery

Post by traufeisen » Mon 03 Aug 2009 08:44

Hi,
running a compiled Query more than one time results in a "object disposed" Exception.

Code: Select all

public static Func> GetPerson =
            CompiledQuery.Compile(
                (DataContext1.DataContext1 ctx, int personId) =>
                (from obj in ctx.Persons where obj.Personid == personId select obj)
                );

for (int i = 0; i  person = GetPerson(dataContext1, 1);
	dataContext1.Dispose();
}
The first call works fine, but the second throws an Exception.
It seems, that the compiled Query still uses the old dataContext or is there a trick to run such a Query with a new dataContext?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 04 Aug 2009 13:53

Thank you for the report, we will investigate the situation.

traufeisen
Posts: 10
Joined: Fri 03 Apr 2009 08:39

Post by traufeisen » Wed 05 Aug 2009 07:52

I´ve found another problem.
When I use a compiled Query, but select a new object, a Notimplemented-Exception is thrown and there is no possibility to rollback the current Transaction.

Code: Select all

public class Foo
{
    public Foo(int id)
    {
        this.Id = id;
    }

    public int Id;
}
public static Func> GetPerson =
            CompiledQuery.Compile(
                (DataContext1.DataContext1 ctx, int personId) =>
                (from obj in ctx.Persons where obj.Personid == personId select new Foo(obj.PersonId))
                ); 
In case of an Error, I try to Rollback the active Transaction, but calling DataContext.Transaction.Rollback(); throws a MySqlException "Commands out of sync; You can't run this command now".
DataContext.Connection.Close(); doesn´t help. The Connections keeps open. With the Transaction still active.

Is there a way to force a connection-close even if connection-pooling is active?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 19 Aug 2009 14:29

We have fixed both errors. The fixes will be available in the nearest build.

Post Reply