Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "ice2burn"

Question

Hello,

Based on this and that issues I faced strange EF Core behavior. But since I can't share project code due to license to reproduce the bug, I have no other options but to ask your help.

In general, then I use OrderBy() EF Core creates separate request for each record in main table (Tickets). So for table of 100 tickets it will make 101 request instead of 1 or 2.

Thanks

Hi,

Trying to map list to my model using ObjectMapper.

public class GetTicketForView
    {
        public TicketDto Ticket { get; set; }
        public string TenantName { get; set; }
        public string ProductName { get; set;}
        public string ProductVersionName { get; set;}
        public TicketStateTableDto TicketState { get; set; }
        public string TicketTypeName { get; set;}
        public string TicketPriorityName { get; set;}
        public List<TicketLinkedUserDto> LinkedUsers { get; set; } // <--
    }

TicketLinkedUsers is many to many relation.

AppService:

. . .
var query = (from o in filteredTickets
             join o1 in _productRepository.GetAll() on o.ProductId equals o1.Id into j1
             from s1 in j1.DefaultIfEmpty()
             join o2 in _productVersionRepository.GetAll() on o.ProductVersionId equals o2.Id into j2
             from s2 in j2.DefaultIfEmpty()
             join o3 in _ticketTypeRepository.GetAll() on o.TicketTypeId equals o3.Id into j3
             from s3 in j3.DefaultIfEmpty()
             join o4 in _ticketPriorityRepository.GetAll() on o.TicketPriorityId equals o4.Id into j4
             from s4 in j4.DefaultIfEmpty()
             join o5 in _ticketStateRepository.GetAll() on o.TicketStateId equals o5.Id into j5
             from s5 in j5.DefaultIfEmpty()
             join o6 in _tenantManager.Tenants on o.TenantId equals o6.Id into j6
             from s6 in j6.DefaultIfEmpty()
             join o7 in _ticketLinkedUsersRepository.GetAll() on o.Id equals o7.TicketId into j7
             from s7 in j7.DefaultIfEmpty()
             select new GetTicketForView() { Ticket = ObjectMapper.Map<TicketDto>(o)
        , ProductName = s1 == null ? "" : s1.Name.ToString()
        , ProductVersionName = s2 == null ? "" : s2.Name.ToString()
        , TicketTypeName = s3 == null ? "" : s3.Name.ToString()
        , TicketPriorityName = s4 == null ? "" : s4.Name.ToString()
        , TicketState = ObjectMapper.Map<TicketStateTableDto>(s5)
        , TenantName = s6 == null ? "" : s6.Name.ToString()
        , LinkedUsers = ObjectMapper.Map<List<TicketLinkedUserDto>>(s7) // <--
});

But it fails with:

Unmapped properties: Capacity

Question

After authorization on Web.Mvc project, user no longer authorized on Web.Public project and vice versa.

Identity server is enabled by default.

OpenId is enabled. I also set options.RequireHttpsMetadata to false to be able to test it on default ports.

I configured Web.Public according to [http://docs.identityserver.io/en/release/quickstarts/3_interactive_login.html])

But looks like, it uses JWT authentication by default.

Hi,

Folowing DEVELOPING AN APPLICATION STEP BY STEP guide I've created new Ticket Service for my project.

All working as expected, but then I join User table in GetAllTickets() method, my _ticketRepository returns empty List. All other data are being filled correctly if I comment that join.

I can't see an issue here. There is no visible errors.

I assume Repository can't include AbpUser Entity this way.

My code:

Ticket Entity:

[Table("Tickets")]
    public class Ticket : FullAuditedEntity<long>, IMustHaveTenant
    {
        public const int MaxTitleLength = 255;
        public const int MinContentLength = 8;
        public const int MaxEmailAddressLength = 255;

        [ForeignKey("TenantId")]
        public virtual Tenant Tenant { get; set; }
        public virtual int TenantId { get; set; }

        [ForeignKey("UserId")]
        public virtual User User { get; set; }
        public virtual long UserId { get; set; }

        [ForeignKey("ProductId")]
        public virtual Product Product { get; set; }
        public virtual int ProductId { get; set; }

        [Required]
        [ForeignKey("ProductVersionId")]
        public virtual ProductVersion ProductVersion { get; set; }
        public virtual int ProductVersionId { get; set; }

        [Required]
        [ForeignKey("TicketTypeId")]
        public virtual TicketType TicketType { get; set; }
        public virtual int TicketTypeId { get; set; }

        [Required]
        [ForeignKey("TicketPriorityId")]
        public virtual TicketPriority TicketPriority { get; set; }
        public virtual int TicketPriorityId { get; set; }

        [Required]
        [ForeignKey("TicketStateId")]
        public virtual TicketState TicketState { get; set; }
        public virtual int TicketStateId { get; set; }

        [Required]
        [MaxLength(MaxTitleLength)]
        public virtual string Title { get; set; }

        [Required]
        [MinLength(MinContentLength)]
        public virtual string Description { get; set; }

        public virtual DateTime? CloseDate { get; set; }

        public virtual DateTime? PlanDate { get; set; }

        public virtual int TicketValue { get; set; }

        public virtual bool IsPrivate { get; set; }

        public virtual bool IsPaid { get; set; }

        public virtual bool IsHostMove { get; set; }

        public Ticket()
        {
            IsPrivate = false;
            IsHostMove = false;
            IsPaid = false;
        }

TicketDto:

[AutoMapFrom(typeof(Ticket))]
    public class TicketListDto : AuditedEntityDto
    {
        public TenantListDto Tenant { get; set; }

        public UserListDto User { get; set; }

        public ProductListDto Product { get; set; }

        public ProductVersionListDto ProductVersion { get; set; }

        public TicketTypeListDto TicketType { get; set; }

        public TicketPriorityListDto TicketPriority { get; set; }

        public TicketStateListDto TicketState { get; set; }

        public string Title { get; set; }

        public string Description { get; set; }

        public DateTime? CloseDate { get; set; }

        public DateTime? PlanDate { get; set; }

        public int TicketValue { get; set; }

        public bool IsPrivate { get; set; }

        public bool IsPaid { get; set; }

        public bool IsHostMove { get; set; }
    }

TicketAppService:

public class TicketAppService : IdentityServerAppServiceBase, ITicketAppService
    {
        private readonly IRepository<Ticket, long> _ticketRepository;

        public TicketAppService(IRepository<Ticket, long> ticketRepository)
        {
            _ticketRepository = ticketRepository;
        }

        public ListResultDto<TicketListDto> GetAllTickets(GetTicketsInput input)
        {
            var tickets = _ticketRepository
                .GetAll()
                .Include(p => p.Tenant)
                // .Include(p => p.User) // <- PROBLEM IS HERE
                .Include(p => p.Product)
                .Include(p => p.ProductVersion)
                .Include(p => p.TicketType)
                .Include(p => p.TicketPriority)
                .Include(p => p.TicketState)
                .ToList();

            return new ListResultDto<TicketListDto>(ObjectMapper.Map<List<TicketListDto>>(tickets));
        }
}

I can see correct relation and FK in my Database as well.

Am I missing something?

Thank you

Showing 1 to 4 of 4 entries