Base solution for your next web application
Open Closed

Power Tools generated code causing Exception #9280


User avatar
0
TimMackey created

Power Tools version 2.4.0.1 was used to create the following entity and code.

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Abp.Domain.Entities.Auditing;
using Abp.Domain.Entities;

namespace ngTTM.TtmDataModel
{
	[Table("TtmExamStates")]
    public class ExamState : Entity 
    {
		[Required]
		public virtual string Guid { get; set; }
		public virtual int ItemsProcesssed { get; set; }
		public virtual int ItemsTotal { get; set; }
		public virtual double MathNotationRenderDuration { get; set; }
    }
}
         public async Task<PagedResultDto<GetExamStateForViewDto>> GetAll(GetAllExamStatesInput input)
         {
            
            var filteredExamStates = _examStateRepository.GetAll()
                        .WhereIf(!string.IsNullOrWhiteSpace(input.Filter), e => false  || e.Guid.Contains(input.Filter))
                        .WhereIf(!string.IsNullOrWhiteSpace(input.GuidFilter),  e => e.Guid == input.GuidFilter);

            var pagedAndFilteredExamStates = filteredExamStates
                .OrderBy(input.Sorting ?? "id asc")
                .PageBy(input);

            var examStates = from o in pagedAndFilteredExamStates
                         select new GetExamStateForViewDto() {
                            ExamState = new ExamStateDto
                            {
                                Guid = o.Guid,
                                ItemsProcesssed = o.ItemsProcesssed,
                                ItemsTotal = o.ItemsTotal,
                                MathNotationRenderDuration = o.MathNotationRenderDuration,
                                Id = o.Id
                            }
                        };

            var totalCount = await filteredExamStates.CountAsync();

            return new PagedResultDto<GetExamStateForViewDto>(
                totalCount,
                await examStates.ToListAsync()
            );
         }

The table data:

The UI appears as follows:

Clicking the columns for the integer values will sort ascending and descending as expected. Clicking the column for the string value (Guid) causes an Exception on the server. Logs.txt:

ERROR 2020-06-29 22:00:06,436 [44   ] Mvc.ExceptionHandling.AbpExceptionFilter - '.' or '(' or string literal expected
'.' or '(' or string literal expected (at index 5)
INFO  2020-06-29 22:00:06,437 [44   ] .Mvc.Infrastructure.ObjectResultExecutor - Executing ObjectResult, writing value of type 'Abp.Web.Models.AjaxResponse'.
INFO  2020-06-29 22:00:06,438 [44   ] c.Infrastructure.ControllerActionInvoker - Executed action ngTTM.TtmDataModel.ExamStatesAppService.GetAll (ngTTM.Application) in 102.9678ms
INFO  2020-06-29 22:00:06,438 [44   ] ft.AspNetCore.Routing.EndpointMiddleware - Executed endpoint 'ngTTM.TtmDataModel.ExamStatesAppService.GetAll (ngTTM.Application)'
INFO  2020-06-29 22:00:06,438 [44   ] Microsoft.AspNetCore.Hosting.Diagnostics - Request finished in 120.4762ms 500 application/json; charset=utf-8
DEBUG 2020-06-29 22:00:08,053 [37   ] HttpRequestEntityChangeSetReasonProvider - Unable to get URL from HttpRequest, fallback to null

The fault occurs on this statement:

            var pagedAndFilteredExamStates = filteredExamStates
                .OrderBy(input.Sorting ?? "id asc")
                .PageBy(input);
  1. Why is generated code not functioning without faults?
  2. What changes need to be made to fix this?

6 Answer(s)
  • User Avatar
    0
    musa.demir created

    Hi @timmackey I could not reproduce it in last version of zero.

    What is your abp version? What is your zero version?

  • User Avatar
    0
    TimMackey created

    Last upgrade: ANZ 8.0.0

    Server: Web.Public\package.json(9): "abp-web-resources": "^3.3.0"

    Client: package.json: "abp-ng2-module": "^5.0.0", "abp-web-resources": "^4.1.0",

  • User Avatar
    0
    musa.demir created

    I could not reproduce it. Can you please share recurring project to [email protected]

  • User Avatar
    0
    TimMackey created

    I'll try an upgrade to ANZ 9.0 and see if that solves the problem. I'll get back to you in a couple of weeks.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @timmackey

    We have upgraded to Metronic 7.0 with AspNet Zero v9.0 and there are many breaking changes in the UI. I just wanted to inform you about this, so maybe you don't want to upgrade and just fix this problem.

  • User Avatar
    0
    TimMackey created

    Problem discovered: dbo.TtmExamStates column 'Guid' was migrated from another table and renamed 'ExamGuid' after Entity Generator regenerated client code.

    Resolution: Fixed code on client to correct name.

    Power Tools Entity Generator appears to be working as designed.