Open Closed

Abp Suite - Custom template cannot use %%dto-field-names-with-type%% in extended code file #7320


User avatar
0
hanntd created

Hi, I'm trying custom abp suite template to generate a custom method in Server.Repository.CustomCode.EfCoreRepository.Extended.txt. In the template I have used this variable: %%dto-field-names-with-type%%, and it seem abp suite didn't understand and generated that text instead of replacing by the correct content: Generated code: Here my custom content in the template: using System; using System.Collections.Generic; using System.Linq; using System.Linq.Dynamic.Core; using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using %%solution-namespace%%.EntityFrameworkCore;

namespace %%solution-namespace%%.%%entity-namespace%% { public class EfCore%%entity-name%%Repository : EfCore%%entity-name%%RepositoryBase, I%%entity-name%%Repository { public EfCore%%entity-name%%Repository(IDbContextProvider<%%only-project-name%%DbContext> dbContextProvider) : base(dbContextProvider) { } public virtual async Task<List<%%entity-name%%>> GetListNoPagedAsync( string? filterText = null, %%dto-field-names-with-type%%%%<if:HasFilterableProperties>%%,%%</if:HasFilterableProperties>%% string? sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, CancellationToken cancellationToken = default) { var query = ApplyFilter((await GetQueryableAsync()), filterText%%<if:HasFilterableProperties>%%, %%</if:HasFilterableProperties>%%%%dto-field-names%%); query = query.OrderBy(string.IsNullOrWhiteSpace(sorting) ? %%entity-name%%Consts.GetDefaultSorting(false) : sorting); return await query.ToListAsync(cancellationToken); } } }


3 Answer(s)
  • User Avatar
    0
    hanntd created

    Anyone can help me on this issue? Thanks?

  • User Avatar
    0
    hanntd created

    Hi @EngincanV, Could you please help me on this issue? Thanks

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, sorry for the late response. ABP Suite only populates these placeholders, those who are defined in the templates of Suite. Files with the .Extended.* postfixes are not re-generated by the ABP Suite and therefore those placeholders will not be populated in the next generation by Suite.

    Instead, you should directly write the code in the place where you defined the related placeholder.

    Check out the documentation for more info: https://docs.abp.io/en/commercial/latest/abp-suite/customizing-the-generated-code

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11