Migrating from v2.6->v5.3 - FieldEntity Field conflicts with EntityField Field in QueryFactory

Posts   
 
    
larkydoo
User
Posts: 45
Joined: 30-Jun-2008
# Posted on: 02-Dec-2021 22:50:44   

I am working with old code from v2.6, bringing it into LLBLGen Pro 5.3. The main issue I'm running up against is that I have a Field table that maps to the FieldBaseEntity/FieldEntity class. When I generate the code in 5.3 (SelfServicing/TwoClasses), the QueryFactory throws a name conflict error because of the following 2 lines:

         ///<summary>Creates a new field object with the name specified and of resulttype 'object'. Used for referring to aliased fields in another projection.</summary>
        /// <param name="fieldName">Name of the field.</param>
        /// <returns>Ready to use field object</returns>
        public EntityField Field(string fieldName)
        {
            return Field<object>(string.Empty, fieldName);
        }

        ...

        /// <summary>Creates and returns a new EntityQuery for the Field entity</summary>
        public EntityQuery<FieldEntity> Field
        {
            get { return Create<FieldEntity>(); }
        }

The specific error is:

The type 'QueryFactory' already contains a definition for 'Field'

What would be the most elegant way to handle this?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 03-Dec-2021 11:12:23   

Hmm, as Field is part of the QuerySpec API, it's part of the runtime, so there's no changing that. In theory you could alter the template and insert 'new' for the Field property but that's not really going to work as you likely want to use the Field method in your code eventually if you're using QuerySpec.

The alternative is to rename the entity Field in the designer. I'm not sure if that's going to be problematic. If it's unacceptable, the last alternative you have is to not generate the QueryFactory, however that would mean you can't use queryspec. I'd opt for renaming the entity.

Frans Bouma | Lead developer LLBLGen Pro
larkydoo
User
Posts: 45
Joined: 30-Jun-2008
# Posted on: 13-Dec-2021 18:48:33   

Renaming the entity worked for me. Thanks!