Insert probrem with 'autoinc' field

Insert probrem with 'autoinc' field

Postby Annavelle » Fri 22 Jun 2012 03:24

con.Tbl.InsertOnSubmit(entity);
con.SubmitChanges();

Column def:
Code: Select all
ALTER TABLE tbl ADD COLUMN id integer;
ALTER TABLE tbl ALTER COLUMN id SET STORAGE PLAIN;
ALTER TABLE tbl ALTER COLUMN id SET NOT NULL;ALTER TABLE tbl ALTER COLUMN id SET DEFAULT nextval('tbl_id_seq'::regclass);


Log:
Code: Select all
INSERT INTO public.tbl (data, name) VALUES (:p1, :p2) RETURNING id
-- p1: Input Int (Size = 0; DbType = Int32) [1]
-- p2: Input Text (Size = 1; DbType = AnsiString) [A]
-- ret1: Output Int (Size = 0; DbType = Int32) []
-- Context: Devart.Data.PostgreSql.Linq.Provider.PgSqlDataProvider Model: MetaModel Build: 4.0.29.0


Exception:
InnerException {"Parameter name is missing.\r\nparametaer name: ret1"}
Annavelle
 
Posts: 3
Joined: Fri 22 Jun 2012 02:56

Re: Insert probrem with 'autoinc' field

Postby MariiaI » Fri 22 Jun 2012 09:33

Thank you for the report. This is a known issue. We are working on it now.
As a workaround you can set the IdGenerator to Sequence and set its 'IsDbGenerated' property to false in id-> Properties-> IdGenerator.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Insert probrem with 'autoinc' field

Postby MariiaI » Mon 25 Jun 2012 12:36

We have fixed the bug that refers to the auto-increment fields ("Parameter name is missing" exception). The corresponding build of LinqConnect will be available for download in about two weeks.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Insert probrem with 'autoinc' field

Postby melle » Thu 12 Jul 2012 07:28

Hi,

Any news on when the new build will be released? I'm running into the same issue, and the suggested workaround does not seem to work for me.

Kind regards,
Melle
melle
 
Posts: 2
Joined: Thu 12 Jul 2012 07:17

Re: Insert probrem with 'autoinc' field

Postby MariiaI » Thu 12 Jul 2012 10:20

melle wrote:Any news on when the new build will be released? I'm running into the same issue, and the suggested workaround does not seem to work for me.

We plan to release the next build of LinqConnect on the next week.
As for the suggested workaround, could you please specify what problems have you encountered with it.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Insert probrem with 'autoinc' field

Postby melle » Thu 12 Jul 2012 12:14

When I set
Code: Select all
  IdGenerator = Sequence, IsDbGenerated = false

I get an exception: invalid name syntax
Note that I did not set the sequence parameter, if I set it to the sequence of the primary key (item_id_seq) I get the exception: "Error on executing DbCommand", with the InnerException: "Parameter name is missing\r\nParameter name: ret1"

To reproduce the error I defined an 'item' table:
Code: Select all
CREATE TABLE item (
   id SERIAL PRIMARY KEY,
   name VARCHAR(10) NOT NULL CHECK (name <> '')
);


I'm attempting to insert an item using:
Code: Select all
using (DevArtTestDataContext dc = new DevArtTestDataContext())
{
        Item i = new Item() { Name = "test" };
        dc.Items.InsertOnSubmit(i);

        dc.SubmitChanges();
}


I'm using VS2010/.NET4/DotConnect for PgSQL 6.0.25 and the Entity Developer to create generate the datacontext.
Hope that helps, I can send you the project files to reproduce the exception if you'd like.
melle
 
Posts: 2
Joined: Thu 12 Jul 2012 07:17

Re: Insert probrem with 'autoinc' field

Postby MariiaI » Fri 13 Jul 2012 11:50

To make it working, you should have the following options for the property "id" in your model:
- IdGenerator = Sequence (isDbGenerated = false, Sequence = item_id_seq);
- Auto-Sync = Never;
- Auto Generated Value = true.

Also, we have sent you a small test project, that demonstrates this workaround.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Insert probrem with 'autoinc' field

Postby MariiaI » Thu 19 Jul 2012 07:27

New build of LinqConnect 4.0.45 is available for download now!
It can be downloaded from http://www.devart.com/linqconnect/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=31&t=24531
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17


Return to LinqConnect (LINQ to SQL support)