Page 1 of 1

Problem with LinQ to mySQL

Posted: Tue 13 Jul 2010 11:29
by Zero-G.
Hey
Using the latest dotConnect for mySQL.
I have created a lqml file and created a DataContext.
Each table has a timestamp field. And for example, one table called user. - This table has several fields and one field (called isLast) it has a default value direct in the database schema, with default value = 1, Allow NULL = True

When I create a "new user"

Code: Select all

Dim nUser as new DataContext.User With {.Name = "TEST"}
DataContext.User.InsertOnSubmit(nUser)
DataContext.SaveChanges 
This code was out of my mind now, so if there is something, wrong please exuse this.

The Problem is now the following:
1) I get an error, which tells me, that the timestamp field has not the right value, - So, I have specify it explicit.

Code: Select all

 Dim nUser as new DataContext.User with {.Name = "TEST", .Zeit = Now}
2) The field value isLast = NULL and not like the default value in the database says: "1", I can't change the design, because "NULL" is a legal thing in my application. - What can I do?

THX

Posted: Wed 14 Jul 2010 13:17
by AndreyR
In case both columns have default values and you wish the corresponding properties to be populated with this values after the insert is performed, you need to set the Auto Generated Value property to true and the AutoSync property to OnInsert in the model designer for both properties.

Posted: Wed 14 Jul 2010 13:52
by Zero-G.
Hey

Thanks, I will try this.

Suggestion: When a column has a Default value, then the Entity Developer should set this automatic, when generating from the DB

Posted: Wed 14 Jul 2010 15:52
by AndreyR
We already perform a parsing of the Default Value and set it in the model in case parsing succeeds.
Could you please send me the script of the column which has a default value but Entity Developer have not generated the Default Value property correctly? We will investigate the situation.