This project has moved. For the latest updates, please go here.

small problem with current vb. templates (smartdate)

Nov 12, 2010 at 10:02 AM
Edited Nov 15, 2010 at 5:57 AM

When creating an editable root object that includes a smartdate field (using vb.net 3.5 templates) the internal_fetch part of the template (probably at this point <%=GetReaderAssignmentStatement(prop)%> line 12) produces code that wont compile.

 

For example Private Sub Fetch(ByVal dr As SafeDataReader)

' Value properties

m_date1 = dr.GetDateTime("date1")

Dim args As New DataPortalHookArgs(dr)

OnFetchRead(args)

End Sub

instead of

Private Sub Fetch(ByVal dr As SafeDataReader)

' value properties

m_date1 = new smartdate(dr.GetDateTime("date1"))

Dim args As New DataPortalHookArgs(dr)

OnFetchRead(args)

End Sub

this problem should appear on more than the editableroot object but i havent tested it yet.

Coordinator
Nov 14, 2010 at 2:03 AM

Hi pandelaras,

Unfortunately I can't help as I don't speak VB.  If you have a correction to propose, I'll be glad to include it in the release.

Regards
Tiago Freitas Leal

Nov 15, 2010 at 5:56 AM
Edited Nov 15, 2010 at 6:02 AM

both c# and vb temlates use the internalfetch.inc (new internalfetch.inc at c#) to properly set the properties with data fetched from datareader. It seems the method is the same <%=GetReaderAssignmentStatement(prop)%>. This isn't a direct template issue as the code is fed from the generator (i believe). All it needs is some provision in the case of the smartdate structure and vb language. This is the code produced currently.

m_date1 = dr.GetDateTime("date1")

and this what it should be

m_date1 = new smartdate(dr.GetDateTime("date1"))

Ι have marked the change in bold.

Any progress on the vb templates btw?

 

 

 

Coordinator
Nov 15, 2010 at 6:39 AM
Edited Nov 15, 2010 at 6:55 AM

Hi Pandelaras,

I guess you are trying to generate an old project. I have the same generated code, well almost.

On declaration I have

Protected _createDate As SmartDate = New SmartDate(True)

and on Fetch I have

_createDate = dr.GetSmartDate("CreateDate"True)

You have GetDateTime while I have GetSmartDate.As I told you, I don't speak VB but VS doesn't report any kind of problem. I have compiled another version using PropertyInfo instead of old style fields (under CslaGenFork respectively Managed and ClassicProperty) and it compiles just fine.

Anyway the C# generated code is the same and also compiles OK.

On a closer look, you have GetDateTime while I have GetSmartDate. Please make sure you are using SmartDate (and not DateTime) for PropertyType.

Developer
Nov 15, 2010 at 12:01 PM
Edited Nov 15, 2010 at 12:04 PM

Hi pandelaras,

I wil be having a look at the VB templates for 4.0 once Tiago is finished with the C# coding.

He is doing some work on the LazyLoad/LoadingScheme that I need for several of my projects and we have a discussion/thread about that.

It is going to be a rather manual conversion of the C# templates on a line by line basis. I am going to leave the codesmith code in C# and just change the ouput from C# to VB to make it easier to change when new releases come out.

Bill

Nov 15, 2010 at 2:35 PM

I changed from autoproperty to managed properties and it worked. I really cant tell what went wrong, but the field types were properly set. The project is old indeed. Sorry for the trouble and thank you for your time!

I also found another one. Line 95 at EditableRootCollection.cst.

MyBase.DataPortal_Update() doesnt work. It needs Child_Update() instead.

Blarm should i continue to post these here or should i email them to you?

 

LazyLoad/LoadingScheme is great btw!

Developer
Nov 15, 2010 at 7:49 PM
pandelaras wrote:

Blarm should i continue to post these here or should i email them to you?

Can you put any vb specific problems in the 'vb templates' discussion, as that is where I will look for them.

Bill