Problem with LinQ to mySQL

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Problem with LinQ to mySQL

Post by Zero-G. » Tue 13 Jul 2010 11:29

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

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 14 Jul 2010 13:17

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.

Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Post by Zero-G. » Wed 14 Jul 2010 13:52

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

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 14 Jul 2010 15:52

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.

Post Reply