TypedList null columns

Posts   
 
    
evdinursan avatar
evdinursan
User
Posts: 25
Joined: 22-Jul-2005
# Posted on: 22-Jul-2005 09:46:58   

Hi! I've just had a surpise! I'm not sure that's normal or not but this is what it's happend: I have a typedlist which contains 2 date columns - Start and Stop. For some rows (in the database), I have NULL value stored in Stop column. When I verify in my code:

if (resultSet[i].Stop != null) { .... }

it never returns null becuase it automatically converts the null value to 1/1/0001.

But if I verify using the IsStopNull() I get the expected result.

disappointed

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 22-Jul-2005 10:40:06   

That's because the properties are typed, and if you have an int field, you can't read a null from it, only value typed values. To keep it consistent, everything has a value, and you have to use the Is...Null properties.

Frans Bouma | Lead developer LLBLGen Pro
bchebrou
User
Posts: 18
Joined: 14-Feb-2006
# Posted on: 23-Jan-2007 16:38:38   

Hello,

I agree with this behavior. But I've a problem when I set a typed list as a datasource of a DataGridView.

I have a column with nullable date. In the datagrid, if the date is null (IsMyDateNull() return true) the value 01/01/0001 01:00 appears.

This is not the case if the datasource is an EntityCollection<T>.

Do I've to write special code, to have blank in the column where the date is null ?

Cheers,

Ben

Edit : LLBLGen version 2.0.0.0 Final, December 6th, 2006 in adapter mode.

Remarks with LLBLGen version 1, this works correctly.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 24-Jan-2007 03:41:14   

I believe this has to do with a typedlist being a datatable and a collection consisting of entities. The solution in this article may be of some help for your situation. http://www.databasepronews.com/databasepronews-51-20061221RemovingNullsfromaDataTable.html

bchebrou
User
Posts: 18
Joined: 14-Feb-2006
# Posted on: 24-Jan-2007 12:50:53   

Hi,

bclubb, I read the article and it's not really my problem. So I continued to search and finally found something.

Let's me explain my problem. I've a client/server application, and the communication between the client and the server is based on remoting (TCP / Binary).

On the client i need to show invoices in a datagrid, so the client call a service on the server by remoting.

On the server i use an adapter (with SqlServer) to fetch a TypedList, and return it to the client.

On the client i set the datasource of my datagrid with the typedlist.

Invoices have a SendDate which can be null in the database. In the datagrid when the SendDate is null the value "01/01/01 01:01" appears in the cells. That's not normal ! I've to see a blank cell.

I think the problem is due to the serialization of the TypedList. Because if i fetch the typedlist on the client side (only a test, because client can't access the database in the real life wink ) blank cells appears for null values.

So, i make an other test in two parts. First part, in a simple application, i fetch a typed list. Bind it to a datagrid, all is correct with nullable date. Second part, i fetch the same typed list, serialize it with a BinaryFormatter. Deserialize the typed list and bind to the datagrid : "01/01/01 01:01" appears for null dates !

I'm using VB.Net 2.0 and LLBLGen V2. With LLBLGen V1 I didn't have the problem... Did you change something between V1 and V2 in the typedlist serialization ? confused

bchebrou
User
Posts: 18
Joined: 14-Feb-2006
# Posted on: 24-Jan-2007 13:23:51   

I confirm the problem occurs during the serialization.

On the server side, if i watch the ItemArray of a line in the typedlist. For the nullable date column (index 7 in my case) i've "System.DBNull".

But on the client side after the remoting process for the same line ItemArray(7) is now "#1:00:00 AM# {Date}" but the Is...Null assoctiated function return True, strange disappointed

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 24-Jan-2007 16:15:45   

If I'm not mistaken the following thread discussed the same issue: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=6523

bchebrou
User
Posts: 18
Joined: 14-Feb-2006
# Posted on: 24-Jan-2007 17:20:14   

Thanks for the link! I didn't find it before i post the first time... flushed