Manager Template conversion question

Posts   
 
    
exp2000
User
Posts: 68
Joined: 13-Apr-2006
# Posted on: 22-Jun-2006 00:17:48   

Hi, I am trying to convert manager templates to VB.NET but I have a problem with interface implementations in PrefetchPathElement2Collection template.

Here is a C# code: public virtual IPrefetchPathElement2Enumerator GetEnumerator() { return new Enumerator(this); }

IEnumerator IEnumerable.GetEnumerator() { return (IEnumerator) GetEnumerator(); }

and here is a VB.NET code that does not work, as these two functions differ only by their return type. Is ther a work around for it.

Public Overridable Function GetEnumerator() As IPrefetchPathElement2Enumerator Implements IPrefetchPathElement2List.GetEnumerator Return New Enumerator(Me) End Function

Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator Return CType(GetEnumerator, IEnumerator) End Function

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 22-Jun-2006 08:49:57   

Name the functions different in VB.NET, that should solve the compiler error. so do for example:

Public Overridable Function GetEnumerator() As IPrefetchPathElement2Enumerator Implements IPrefetchPathElement2List.GetEnumerator Return New Enumerator(Me) End Function

Public Function GetEnumeratorExplicit() As IEnumerator Implements IEnumerable.GetEnumerator Return CType(GetEnumerator, IEnumerator) End Function

Frans Bouma | Lead developer LLBLGen Pro
exp2000
User
Posts: 68
Joined: 13-Apr-2006
# Posted on: 22-Jun-2006 15:22:55   

Yep that's what I figured out I'll have to do. Anyway, when I finish conversion would anybody be interested for me to place somwhere for others?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 22-Jun-2006 16:02:34   

exp2000 wrote:

Yep that's what I figured out I'll have to do. Anyway, when I finish conversion would anybody be interested for me to place somwhere for others?

When you're done I could check them into the svn tree as vb.net templates simple_smile

Frans Bouma | Lead developer LLBLGen Pro
exp2000
User
Posts: 68
Joined: 13-Apr-2006
# Posted on: 23-Jun-2006 18:02:08   

Ok, I am starting to run some code generation test and one of the templates is giving me trouble (EntityManagerBaseTemplate) . Entity never get's set to anything and template trhows an error. This at the very begging of the template when it calls to GetPrimaryKeyFields. If I look at the Entity is set to Nothing. Now I do not know what set's entity and how (_executingManager has Entities collection) and Entity is in there. Can anybody help?

Public Function GetPrimaryKeyFields() As ArrayList 'System.Diagnostics.Debugger.Break() If Entity.HierarchyType = InheritanceHierarchyType.TargetPerEntityHierarchy Then Return Entity.GetRootOfHierarchy.PrimaryKeyFields Else Return Entity.PrimaryKeyFields End If End Function

exp2000
User
Posts: 68
Joined: 13-Apr-2006
# Posted on: 23-Jun-2006 18:03:17   

Here is the begining of the template, which matches C# template

<[ System.IO ]> <[ System.Text ]> <[ SD.LLBLGen.Pro.LptParser ]> <[ SD.LLBLGen.Pro.ApplicationCore ]> <[ SD.LLBLGen.Pro.ApplicationCore.Entities ]> Imports System Imports <%=BaseNameSpace%> Imports <%=BaseNameSpace%>.DatabaseSpecific Imports <%=BaseNameSpace%>.EntityClasses Imports <%=BaseNameSpace%>.FactoryClasses Imports <%=BaseNameSpace%>.HelperClasses

Imports SD.LLBLGen.Pro.ORMSupportClasses

Namespace <%=BaseNameSpace%>.Core.Managers

Public Class <%=ObjectName%>ManagerBase : ManagerBase
    Protected Shared defaultSorter As SortExpression = Nothing

    ''' <summary>
    ''' Private constructor prohibiting instantiation.
    ''' </summary>
    Protected Sub New
        '''Private constructor prohibiting instantiation
    <%If (GetPrimaryKeyFields().Count > 0) Then%>
        defaultSorter = New SortExpression( SortClauseFactory.Create( <%=ObjectName%>FieldIndex.<%=CType(GetPrimaryKeyFields()(0),EntityFieldDefinition).FieldName%>, SortOperator.Ascending ) )
    <%End If%>
    End Sub
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 25-Jun-2006 12:28:44   

exp2000 wrote:

Ok, I am starting to run some code generation test and one of the templates is giving me trouble (EntityManagerBaseTemplate) . Entity never get's set to nothing and template trhows an error. This at the very begging of the template when it calls to GetPrimaryKeyFields. If I look at the Entity is set to Nothing. Now I do not know what set's entity and how (_executingManager has Entities collection) and Entity is in there. Can anybody help?

I'm not following the question, flushed . Is the problem that you get an exception because 'Entity' is Nothing or do you expect it to be Nothing and it never becomes Nothing?

Frans Bouma | Lead developer LLBLGen Pro
exp2000
User
Posts: 68
Joined: 13-Apr-2006
# Posted on: 25-Jun-2006 15:58:48   

I am sorry, I re-read my question, and it really does not make any sense. Entity is set to nothing, and it should be set to something so I can get the PK.

exp2000
User
Posts: 68
Joined: 13-Apr-2006
# Posted on: 25-Jun-2006 16:16:53   

I found a problem, I had End Namespace hanging in the middle of the code for EntityManagerBaseTemplate.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 25-Jun-2006 17:03:48   

So I can mark this as done? simple_smile

Frans Bouma | Lead developer LLBLGen Pro
exp2000
User
Posts: 68
Joined: 13-Apr-2006
# Posted on: 07-Sep-2006 15:37:21   

Yes, I've been away for a while on vacation and other projects. I have finished converting the manager templates to VB.NET and I have found one potential problem with templates that is described in this post: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=6145&HighLight=1

How do I go about sharing these templates with community?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 08-Sep-2006 09:48:19   

Are these for v1 or v2?

Frans Bouma | Lead developer LLBLGen Pro
exp2000
User
Posts: 68
Joined: 13-Apr-2006
# Posted on: 08-Sep-2006 19:17:34   

v1

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 08-Sep-2006 20:46:19   

You could mail them to support AT llblgen.com and I can check them into the repository if you want to simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 09-Sep-2006 10:05:34   

Received them. simple_smile Will check them into the repository. simple_smile

Frans Bouma | Lead developer LLBLGen Pro