Linq with Null values

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Andrew
Posts: 9
Joined: Thu 28 Aug 2008 20:24

Linq with Null values

Post by Andrew » Wed 19 Nov 2008 22:15

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

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

Post by AndreyR » Thu 20 Nov 2008 11:43

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.

alworks
Posts: 13
Joined: Thu 20 Nov 2008 15:53

Post by alworks » Thu 20 Nov 2008 15:58

Hello
I have the same problem with LINQ to PostgreSQL. Is there any fix?

Thank you,
Aleksander

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

Post by AndreyR » Fri 21 Nov 2008 07:31

I have sent you the fix to the e-mail address you provided in your profile.

alworks
Posts: 13
Joined: Thu 20 Nov 2008 15:53

Post by alworks » Fri 21 Nov 2008 08:46

AndreyR wrote:I have sent you the fix to the e-mail address you provided in your profile.
Problem is solved.
Thank you,
Aleksander

alworks
Posts: 13
Joined: Thu 20 Nov 2008 15:53

Post by alworks » Mon 24 Nov 2008 13:12

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

alworks
Posts: 13
Joined: Thu 20 Nov 2008 15:53

Post by alworks » Mon 24 Nov 2008 13:28

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.

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

Post by AndreyR » Mon 24 Nov 2008 14:58

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.

mheijink
Posts: 1
Joined: Tue 02 Dec 2008 12:51

inserting null values Oracle

Post by mheijink » Tue 02 Dec 2008 12:54

Hi,

Do you have a workaround so that I can insert null values when using oracle?

Thanks

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

Post by AndreyR » Tue 02 Dec 2008 13:23

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.

Post Reply