<cite>ismcagdas: </cite> Hi @Ice2burn,
You souldn't use Entities in your Dtos. Probably there is a serialization problem while sending your list to client. Can you replace entities with their related Dtos in your TicketListDto class ? You can also check Logs.txt file under your web project to see if there is an error.
Hi, all Entities were replaces by related Dtos. An issue still exists. If i uncomment
.Include(p => p.User)
line, ticketRepository returns empty list.
Also, there is no errors or warnings in the Log.
Edited the code above according to my changes.
<cite>alirizaadiyahsi: </cite> Hi @Ice2burn,
Are you getting only users? What about other relations (tenant, product, etc...)?
Hi, I'm gettin no data at all if users included.
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