VB templates, using delegate method problems.

VB templates, using delegate method problems.

Old forum URL: forums.lhotka.net/forums/t/1918.aspx


Tommybouy posted on Thursday, December 07, 2006

Firstly, I do find the templates very useful but I have some questions about their use and the code they generate. We use split partial classes and in the user portion of the code is where the initialize method is and all of the delegate usage lines are remarked out. We have some properties that are not persisted but are filled with data pulled during the select statement. So we would like to use the FetchObjectCompleteDelegate to load the values into the properties. The delegate never actually gets used because it seems the

<NonSerialized()> _

Private fetchObjectCompleteDelegate As Action(Of SafeDataReader) = Nothing

line gets hit after the initialize has already taken place so when it checks the delegate its value is nothing. Hopefully this makes sense.

Is there any documentation about how to fill in the values in CodeSmith prior to generating code to ensure the code generates as expected?

Thanks

Tom

rasupit replied on Thursday, December 07, 2006

Tom,
VB executes constructor on base class before executing definition on your subclass which contain the above definition.  You can simply remove the assignment to nothing.

You can find the same issue reported at http://www.codeplex.com/CSLAcontrib/WorkItem/View.aspx?WorkItemId=2453
and the second comment (my comment) explained how to fix it.

Ricky

Tommybouy replied on Tuesday, December 12, 2006

Thanks Ricky.

 

Copyright (c) Marimer LLC