AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

Nullable columns and Properties relationship. #275

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. If you have database columns that are nullable only date columns get
converted to Nullable (of DateTime).
2. When you use the dataportal_Fetch, the map method then converts all the
column values using reader.item("xyzColumn") which assumes that the
destination property is a Nullable (of ColumnVariableType).
3. When updating a record that has been retieved in step on, it's possible
that the original field was Null and so the public property will be
Nothing. The command parameter population will then not work as expected
because setting a command parameter value to nothing results is a sql
exception.

What is the expected output? What do you see instead?
Need to make nullable database column consistent with dates and Foreign key
fields (which are also getting correctly set to nullable (of xyz) properties.
Alternatively if standard properties for a business object shouldn't be
Nullable(of xyz) then the Dataportal_Fetch() Map needs to retrieve the data
with the LoadProperty(_abc,Reader.GetVariableType("columnxyz")) rather that
the LoadProperty(_abc,Reader.Item("columnxyz")) method. This would require
more complex logic in the Map.cst file to handle the regular fields, date
fields and relationship fields.

What version of the product are you using?
r1439

Original issue reported on code.google.com by JenasysD...@gmail.com on 24 Feb 2010 at 6:10

GoogleCodeExporter commented 9 years ago
Blake, I have a whole bunch of code in my current app like this.

If IsNumeric(BO.Property) andalso (CInt(cm.Parameters.Item("@pProperty").Value) 
= 0) Then
   cm.Parameters.Item("@pProperty").Value = DBNull.Value
End if 
If GetType(Bo.Property) = System.String
AndAlso(cm.Parameters.Item("@pProperty").Value.ToString().Trim = String.Empty) 
Then
                cm.Parameters.Item("@pProperty").Value = DBNull.Value
End If

This is to handle the Nullable columns in the database.  I couldn't see logic 
like
this in your codegen.

Original comment by JenasysD...@gmail.com on 24 Feb 2010 at 6:49

GoogleCodeExporter commented 9 years ago
Attached is potential solution the includes using ADOHelper to include code 
that does
basic DBNull.Value conversion. Have a look at ADOHelp.vb and Consultant.vb as 
I've
added a whole series of "replacement" code to fix null data errors.

I've also attached the nunit results image.  Getting close!

Original comment by JenasysD...@gmail.com on 24 Feb 2010 at 10:05

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 24 Feb 2010 at 11:24

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 24 Feb 2010 at 12:04

GoogleCodeExporter commented 9 years ago
Attached is an upgraded Nunit Test for the following location, that you can use 
to
confirm changes to the templates to ensure dataportal Insert/Updates save Null 
values
were possible.
Source:
Projects\Framework-Samples\Csla\VisualBasic\PetShop\Source\PetShop.Tests\PetShop
.Tests.StoredProcedures\

Original comment by JenasysD...@gmail.com on 3 Mar 2010 at 11:46

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 19 Mar 2010 at 3:01

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 19 Mar 2010 at 3:05

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 21 Jun 2010 at 8:05

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 21 Jun 2010 at 8:07