Conversion from IPredicateExpression to IEntity

Posts   
 
    
JMitchell avatar
JMitchell
User
Posts: 128
Joined: 01-Sep-2006
# Posted on: 09-Jul-2008 15:54:27   

Two of the tables in my database are Personnel and Nationality. I recently had the need to add a ThreeLetterCode field to the Nationality table and a CountryOfResidence field in the Personnel table, linked to the Nationality table. There is already a Nationality fields in the Personnel table which is linked so I have created a second link between the two tables.

I expected everything to be fine so I refreshed the catalog, generated the code and tried to rebuild it only to see errors in NationalityEntityBase.vb and SalutationEntityBase.vb: Option Strict On disallows implicit conversions from 'SD.LLBLGen.Pro.ORMSupportClasses.IPredicateExpression' to 'SD.LLBLGen.Pro.ORMSupportClasses.IEntity'

In the GUI there are four relationships between Salutation and Nationality via Personnel, none of which are needed. Can I remove these relations from the GUI? If so how? I don't want to remove the individual links between Nationality and Personnel and Salutation and Personnel. Is it possible that this is causing the problem?

The generated code where the error is being flagged is:

''' <summary>Retrieves all related entities of type 'PersonnelEntity' Imports a relation of type '1:n'.</summary>
''' <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
''' <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
''' <param name="filter">Extra filter to limit the resultset.</param>
''' <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
Public Overridable Function GetMultiPersonnel(forceFetch As Boolean, entityFactoryToUse As IEntityFactory, Filter As IPredicateExpression) As TravBase.CollectionClasses.PersonnelCollection
    If ( Not _alreadyFetchedPersonnel Or forceFetch Or _alwaysFetchPersonnel) AndAlso Not MyBase.IsSerializing AndAlso Not MyBase.IsDeserializing AndAlso Not MyBase.InDesignMode Then
        If MyBase.ParticipatesInTransaction Then
            If Not _personnel.ParticipatesInTransaction Then
                MyBase.Transaction.Add(_personnel)
            End If
        End If
        _personnel.SuppressClearInGetMulti = Not forceFetch
        If Not entityFactoryToUse Is Nothing Then
            _personnel.EntityFactoryToUse = entityFactoryToUse
        End If
        _personnel.GetMultiManyToOne(Me, Nothing, Nothing, Filter)
        _personnel.SuppressClearInGetMulti = False
        _alreadyFetchedPersonnel = True
    End If
    Return _personnel
End Function

I tried updating to the latest version of LLBLGen Pro from 2.5 and regenerating - that gave me loads more errors in my related project but didn't get rid of this problem! Edit: I've got rid of all problems except this one now

Any ideas as to how to get round this problem?

I am developing against .NET 2.0 in Visual Studio 2008 using VB

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 09-Jul-2008 17:02:07   

Option Strict On disallows implicit conversions from 'SD.LLBLGen.Pro.ORMSupportClasses.IPredicateExpression' to 'SD.LLBLGen.Pro.ORMSupportClasses.IEntity'

Most probably you have used a reserved word or something. Do you have an entityField or a field mapped on a relation called "Filter"?

In the GUI there are four relationships between Salutation and Nationality via Personnel, none of which are needed. Can I remove these relations from the GUI? If so how?

Yes you can. Select the specified relation in the Relations tab, and then click on the button called "Actions on selected relations", then select either of the "toggle hide flag.." options

JMitchell avatar
JMitchell
User
Posts: 128
Joined: 01-Sep-2006
# Posted on: 09-Jul-2008 17:10:30   

I think I've found the problem.

I tried generating it to a new folder and it works. The problem then was that I have quite a bit of custom code so I can't just that one.

I compared the two projects and the old one still has an EntityBaseClasses folder and it was files within that that had the problem. I excluded that folder from the project and it compiled OK.

Why would a regenerated project file reference the EntityBaseClasses folder still?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 09-Jul-2008 17:30:53   

To clean the project when re-generating code, please set the CleanUpVsNetProjects project property to true

[quotenick="docs"]CleanUpVsNetProjects When set to true, the VS.NET project file task performer will first remove all file references for files from an existing VS.NET project file, before adding the files generated. For VS.NET 2005 projects, it will remove all files generated by LLBLGen Pro, as these are marked with a Generator tag. Note: Use with care as an old VS.NET project may contain references to files which aren't marked with LLBLGen Pro specific XML elements/attributes, so all file references are removed, which thus also means that references to files you've added yourself to the project are removed as well, which forces you to re-add the references to those files to the VS.NET project manually.[/quote]

JMitchell avatar
JMitchell
User
Posts: 128
Joined: 01-Sep-2006
# Posted on: 09-Jul-2008 17:32:30   

Wouldn't this result in losing the custom code I have in other files?

_Edit No, sorry. I misunderstood. It's removing the references only.

Good stuff, thanks_