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

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

Postby 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() );

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

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

Postby 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
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

Postby lc4pro » Mon 05 May 2014 21:05

I sent a mail with the project and some extra info.
Thank you.
lc4pro
 
Posts: 51
Joined: Thu 12 Jul 2012 08:16

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

Postby 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/?ExecuteDynamicMethods.html
http://www.devart.com/linqconnect/docs/?ExtensibilityMethods.html
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

Postby 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:
lc4pro
 
Posts: 51
Joined: Thu 12 Jul 2012 08:16

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

Postby 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.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17


Return to LinqConnect (LINQ to SQL support)