Print Page | Close Window

Setting NULL into a column

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1074
Printed Date: 14-May-2025 at 10:17pm


Topic: Setting NULL into a column
Posted By: dkearney1
Subject: Setting NULL into a column
Date Posted: 28-Jan-2009 at 12:05pm
I can't believe I'm not getting this.

I've got a table ContractFunds, with a nullable column FundSource, which refers to a FundSource table. The ServerModel and DomainModel entities exist and have no interesting bits.

I create ContractFund record by hand, having NULL in the FundSource column, and having retrieved this record via IdeaBlade, the FundSource property is (correctly) a NullEntity (IsNullEntity == true). I continue by retrieving an appropriate FundSource, set it into the ContractFund, save, and the record in the database is updated. Now I want to undo that last action. I retrieve the ContractFund, set the FundSource to null, which appears to have the desired effect, but after the save the record in the database still has a value in the FundSource column. I know the save worked because the housekeeping columns have updated. When I crank up the Profiler, the update statement shows the housekeeping columns being updated, but the changes to the FundSource column aren't there.

Here's the code:
     Contract testContract = Contract.Get(em, 7);
     ContractFund fund = testContract.ContractFunds[0];
     FundSource fundSource = fund.FundSource;

     if (fundSource.EntityAspect.IsNullEntity)
     {
          FundSource newSource = FundSource.Get(em, "FAA");
          fund.FundSource = newSource;
     }
     else
     {
          fund.FundSource = null;
     }

     if (em.HasChanges())
          em.SaveChanges();

What am I missing?

-------------
Dan
�In anything at all, perfection is finally attained not when there is no
longer anything to add, but when there is no longer anything to take away.�
Saint-Exup�ry
Wind, Sand, and Stars



Replies:
Posted By: dkearney1
Date Posted: 04-Feb-2009 at 5:55am
Any help?

-------------
Dan
�In anything at all, perfection is finally attained not when there is no
longer anything to add, but when there is no longer anything to take away.�
Saint-Exup�ry
Wind, Sand, and Stars


Posted By: kimj
Date Posted: 04-Feb-2009 at 9:41am

Dan, 

Sorry, your first post somehow slipped by us.
 
This problem is actually due to a bug, which we fixed in early January.  Unfortunately, we haven't had a release since December, so this is no help to you right now.  The next release is tentatively scheduled for late this month (February). 


Posted By: dkearney1
Date Posted: 04-Feb-2009 at 10:40am
OK, for the time being I'll add records to the FundSource table that represent the lack of a fund source and wait for the fix.

How tentative is "tentatively scheduled" ?

-------------
Dan
�In anything at all, perfection is finally attained not when there is no
longer anything to add, but when there is no longer anything to take away.�
Saint-Exup�ry
Wind, Sand, and Stars


Posted By: kimj
Date Posted: 04-Feb-2009 at 10:45am
Good question.  The schedule is currently under discussion, but it will be 2 - 6 weeks (with engineering voting for 2 weeks).  I'll post again once we have a firm date, or you can contact support directly if I'm remiss.



Print Page | Close Window