Errors in generated code

Posts   
 
    
Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 30-Jan-2007 17:58:48   

I'm using LLBL 2, VS2005 with VB.Net, and SQL Server 2005.

I have some errors in the generated code. Even if I generate the code in a fresh directory, I still get the same error in this line of the BoxColumnEntityBase class:

fetchResult = newEntity.FetchUsingPK(CType(Me.Fields(CInt(BoxColumnFieldIndex.BoxTypeID** ).TypeConverterToUse.ConvertTo(Me.BoxTypeID**, GetType(System.Int32)), System.Int32))

Errors generated:

'TypeConverterToUse' is not a member of 'Integer'.

'Int32' is a type in 'System' and cannot be used as an expression.

Syntax error in cast operator; two arguments separated by comma are required.

I don't want to modify the generated code - is there something I should do different in the code generation?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 30-Jan-2007 18:12:56   

The generated code shouldn't fail on compile so something is wrong in the templates perhaps.

Could you explain what you did, e.g. which field is a typeconverter field etc. ? or attach the .lgp file (if you want to, you can also open a new thread in teh helpdesk forum so others can't see /download your attached .lgp file).

Edit: I think a ')' was misplaced by the TDL code generation engine. (in the CallByPKReference statement handler)

Frans Bouma | Lead developer LLBLGen Pro
Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 30-Jan-2007 19:16:44   

This is the function with the error in it:

''' <summary>Retrieves the related entity of type 'BoxTypeEntity', Imports a relation of type 'n:1'</summary>
''' <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
''' <returns>A fetched entity of type 'BoxTypeEntity' which is related to this entity.</returns>
Public Overridable Function GetSingleBoxType(forceFetch As Boolean) As BoxTypeEntity
    If ( Not _alreadyFetchedBoxType Or forceFetch Or _alwaysFetchBoxType) AndAlso Not MyBase.IsSerializing AndAlso Not MyBase.IsDeserializing Then
            Dim newEntity As New BoxTypeEntity()
        If MyBase.ParticipatesInTransaction Then
            MyBase.Transaction.Add(newEntity)
        End If
        Dim fetchResult As Boolean = False
        If MyBase.CheckIfLazyLoadingShouldOccur(BoxColumnEntity.Relations.BoxTypeEntityUsingBoxTypeID) Then
            fetchResult = newEntity.FetchUsingPK(CType(Me.Fields(CInt(BoxColumnFieldIndex.BoxTypeID).TypeConverterToUse.ConvertTo( Me.BoxTypeID, GetType(System.Int32)), System.Int32))
        End If
        If Not _boxTypeReturnsNewIfNotFound AndAlso Not fetchResult Then
            Me.BoxType = Nothing
        Else
            If Not MyBase.ActiveContext Is Nothing AndAlso fetchResult Then
                newEntity = CType(MyBase.ActiveContext.Get(newEntity), BoxTypeEntity)
            End If
            Me.BoxType = newEntity
            _alreadyFetchedBoxType = fetchResult
        End If
        If MyBase.ParticipatesInTransaction AndAlso Not fetchResult Then
            MyBase.Transaction.Remove(newEntity)
        End If
    End If
Return _boxType
End Function

I don't have any field, property, function, etc. named TypeConverterToUse. I assume it's in a LLBL class that's missing from my project. Also when I search for 'TypeConverterToUse' I only find it in this class. The table it's representing has 3 integers in it and one varchar(3). 1 integer is the primary key, another integer is a foreign key. There is only one relationship to the table.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 30-Jan-2007 19:56:24   

Have you defined a typeconverter on the PK field?

It would be helpful if you could mail us the .lgp file (support AT llblgen.com) or if you could open a thread in the helpdesk forum so the .lgp file could be attached without worries, it would be great so we can generate code with it and see where things go wrong.

Frans Bouma | Lead developer LLBLGen Pro
Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 30-Jan-2007 20:20:53   

I sent the lgp file to support.

I looked at the table in question in the llbl designer and I saw that one integer field in the table (the foreign key) had the typeconverter to use as a boolean. There are 2 tables in the database that are structured the same (BoxRow and BoxColumn) and they both had the same type converter set on the same field in them (BoxTypeID). I know I wouldn't have done this. I deleted the table entities, re-imported the from the database catalog, and this time the type converter did not get set. After regenerating the code - there were no errors. So the question is how 2 of the integer fields (the foreign keys) got a typeconverter of boolean set on them.

Thanks for the fast responses in the forums!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 30-Jan-2007 20:38:07   

Ah you found that yourself as well simple_smile I was just going to post that simple_smile .

I don't know how the type converters got assigned to the fields, though it's one click of a button, or maybe you ran the plugin by accident or toyed with the type conversion definitions earlier on in the project?

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 31-Jan-2007 14:18:04   

I found the issue in the tdl interpreter. It's fixed in hte next build. Not that that will make your code work, as the type converter shouldn't be there, but the code should be compilable.

Frans Bouma | Lead developer LLBLGen Pro