Open Closed

CRUD Page Generator navigations to the same model but different property name produces invalid Angular output #9167


User avatar
0
david1 created

When generating a page for a model with two differently named fields but pointing to the same model, the outputted generated Angular component is invalid due to duplicated lookup properties.

See below for invalid output:

export abstract class AbstractGradeAlternateDetailViewService {
  protected readonly fb = inject(FormBuilder);
  protected readonly track = inject(TrackByService);

  public readonly proxyService = inject(GradeAlternateService);
  public readonly list = inject(ListService);

  public readonly getGradeLookup = this.proxyService.getGradeLookup;

// The below line is being doubled up-- either we need a way to rename the property to something different or the outputted code shouldn't duplicate it a second time
// The fix workaround now is to just manually delete the below line but this change will get overwritten if the file is ever re-generated 
  public readonly getGradeLookup = this.proxyService.getGradeLookup;
  
...

}

Cause appears to be because we have two navigation properties pointing to the same model (Grade); however, this is valid C# as one of the property names is for GradeId and the other is for ParentGradeId:

  • Exception message and full stack trace:
  • Steps to reproduce the issue:

1 Answer(s)
  • User Avatar
    0
    sumeyye.kurtulus created
    Support Team Angular Expert

    Hello! You're right—the generated proxy service is reflecting the lookup properties based on the navigation fields, and in this case, it's duplicating them due to both pointing to the same model (Grade).

    This behavior comes from the controller generation pattern, which typically results in something like:

    [HttpGet]
    [Route("entity-one-lookup")]
    public virtual Task<PagedResultDto<LookupDto<Guid>>> GetEntityOneLookupAsync(LookupRequestDto input)
    {
      return _entityThreesAppService.GetEntityOneLookupAsync(input);
    }
    

    The duplication issue is acknowledged and we're planning to address it in a future release. For now, the manual removal workaround is the best option—though we understand it's not ideal, especially when files are regenerated.

    If you believe the issue stems more from the controller generation logic itself, feel free to share more details and I’d be happy to look into it further with you.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on May 12, 2025, 05:22