Page 1 of 1

Insert probrem with 'autoinc' field

Posted: Fri 22 Jun 2012 03:24
by Annavelle
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"}

Re: Insert probrem with 'autoinc' field

Posted: Fri 22 Jun 2012 09:33
by MariiaI
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.

Re: Insert probrem with 'autoinc' field

Posted: Mon 25 Jun 2012 12:36
by MariiaI
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.

Re: Insert probrem with 'autoinc' field

Posted: Thu 12 Jul 2012 07:28
by melle
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

Re: Insert probrem with 'autoinc' field

Posted: Thu 12 Jul 2012 10:20
by MariiaI
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.

Re: Insert probrem with 'autoinc' field

Posted: Thu 12 Jul 2012 12:14
by melle
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.

Re: Insert probrem with 'autoinc' field

Posted: Fri 13 Jul 2012 11:50
by MariiaI
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.

Re: Insert probrem with 'autoinc' field

Posted: Thu 19 Jul 2012 07:27
by MariiaI
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