Page 1 of 1
Linq with Null values
Posted: Wed 19 Nov 2008 22:15
by Andrew
Hello
I was wondering if support for nullable fields will be added.
For example, I have a field in the MySQL database of Decimal type. This type can be null. The shema modeller reflects this but the code generated does not.
I noticed a new version of Linq has been provided but have not been able to upgrade yet. So sorry if this fix has already been implemented.
Thanks
AFrieze
Posted: Thu 20 Nov 2008 11:43
by AndreyR
We have fixed this problem. This fix will be available in next build of dotConnect for MySql.
If you wish, send us an empty e-mail with subject "LINQ to MySQL Nullable trouble", and we will send you a workaround.
Posted: Thu 20 Nov 2008 15:58
by alworks
Hello
I have the same problem with LINQ to PostgreSQL. Is there any fix?
Thank you,
Aleksander
Posted: Fri 21 Nov 2008 07:31
by AndreyR
I have sent you the fix to the e-mail address you provided in your profile.
Posted: Fri 21 Nov 2008 08:46
by alworks
AndreyR wrote:I have sent you the fix to the e-mail address you provided in your profile.
Problem is solved.
Thank you,
Aleksander
Posted: Mon 24 Nov 2008 13:12
by alworks
There is a problem with foreignkey values set to null.
Example:
Position entity has properties:
Id (primary key)
Name (string)
FinancialId (integer, foreign key, association with table Financial, allows null)
Code: Select all
var position = (from p in db.Position where p.Id == 6 select p).Single();
position.Name = "new name";
db.SubmitChanges();
Above code throws InvalidCastException in code auto-generated by EntityDeveloper:
Code: Select all
[Association(Name="Financial_Position", Storage="_Financial", ThisKey="FinancialId", IsForeignKey=true)]
public Financial Financial
{
get
{
return this._Financial.Entity; //exception occurs here!!!
}
No mater what property of Position entity is changed. If any of foreign keys (in above example FinancialId) has null value - this exception is thrown.
Probably there is something with patched template.
Thank you,
Aleksander
Posted: Mon 24 Nov 2008 13:28
by alworks
Update for above problem.
Code: Select all
var position = (from p in db.Position where p.Id == 6 select p).Single();
position.Name = "new name";
position.FinancialId = 4;
db.SubmitChanges();
After changing all foreign keys to not null values, above code throws identical exception in identical place.
Identical code but for Sql Server LINQ to SQL is executing without problems.
Thx, A.
Posted: Mon 24 Nov 2008 14:58
by AndreyR
Could you please send us the script of your DB objects?
Also, try updating to the latest version of dotConnect for MySQL, if you haven't done this yet. This may help.
inserting null values Oracle
Posted: Tue 02 Dec 2008 12:54
by mheijink
Hi,
Do you have a workaround so that I can insert null values when using oracle?
Thanks
Posted: Tue 02 Dec 2008 13:23
by AndreyR
Yes, the workaround for Oracle is also available.
Send me (andreyr * devart * com) an e-mail containing your forum nickname and I will send you the workaround too.