Cannot insert new record in Postgresql 8.4 but no exception is thrown

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
lc4pro
Posts: 51
Joined: Thu 12 Jul 2012 08:16

Cannot insert new record in Postgresql 8.4 but no exception is thrown

Post by lc4pro » Thu 01 May 2014 20:26

I'm trying to know when to hook to extensibility methods.
So, this is my first test on inserting a record from code.

As stated in the subject, nothing happens (the server table remains empty), but no exception are thrown or errors are raised ( context.HasErrors is false ).

Here is the code. (Edit May/02) May be important to point that Car is a subclass of Vehicles, all the hierarchy in one table.

What am I doing the wrong way?

TIA

Code: Select all

            TestDataContext context = new TestDataContext();
            Console.WriteLine( context.Connection.ConnectionString );
            if (!context.Connection.ConnectionString.Contains( "Password" ))
                context.Connection.ConnectionString += ";Password=xxx";
            context.Connection.Open();
            context.Transaction = context.Connection.BeginTransaction();
            Car c = new Car();
            c.Brand = "Dodge";
            context.Vehicles.InsertOnSubmit( c );
            Console.WriteLine( "Submitting " );
            context.SubmitChanges();
            context.Transaction.Commit();
            Console.WriteLine( "HasErrors = " + context.HasErrors.ToString() );


MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Cannot insert new record in Postgresql 8.4 but no exception is thrown

Post by MariiaI » Mon 05 May 2014 09:11

We couldn't reproduce this issue in our environment with the latest build of LinqConnect 4.4.484. We are sending you a sample project to the e-mail address you have provided in your forum profile. Please check that the letter is not blocked by your mail filter. Please modify our sample project so that the issue could be reproduced and send it back to us, or send us your sample project.

JIC: you can use logging to see the generated SQL query: http://www.devart.com/linqconnect/docs/?Logging.html

lc4pro
Posts: 51
Joined: Thu 12 Jul 2012 08:16

Re: Cannot insert new record in Postgresql 8.4 but no exception is thrown

Post by lc4pro » Mon 05 May 2014 21:05

I sent a mail with the project and some extra info.
Thank you.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Cannot insert new record in Postgresql 8.4 but no exception is thrown

Post by MariiaI » Tue 06 May 2014 09:31

Thank you for the additional information. Please add this code to the CrmSampleDataContext.CrmDataContextExtension.cs file in your sample project:

Code: Select all

 partial void InsertVehicle(Vehicle instance)
   {
    Console.WriteLine( "Inserting {0}", instance.Brand );
    this.ExecuteDynamicInsert(instance);
   }
The ExecuteDynamicInsert method is called inside overridden methods to redelegate the task of generating and executing dynamic SQL for insert operations to LinqConnect.
For more information please refer to:
http://www.devart.com/linqconnect/docs/ ... thods.html
http://www.devart.com/linqconnect/docs/ ... thods.html

lc4pro
Posts: 51
Joined: Thu 12 Jul 2012 08:16

Re: Cannot insert new record in Postgresql 8.4 but no exception is thrown

Post by lc4pro » Tue 06 May 2014 11:34

Thank you a lot. As I always say: "Please read the manual before any use of the appliance"... :oops:

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Cannot insert new record in Postgresql 8.4 but no exception is thrown

Post by MariiaI » Tue 06 May 2014 11:40

Glad to see that the issue was resolved. If you have any further questions, feel free to contact us.

Post Reply