Base solution for your next web application

Activities of "netsolpro"

I am trying to add the Creator UserName to a grid. I can only seem to get the Name. CreatorUserName is the First Name for the APB.User. I am trying to acquire and display the actual UserName for the user that created a record.

Thanks!

public async Task<PagedResultDto<WidgetListDto>> GetWidgets(WidgetFilteredInputDto input)
        {

            var query = _WidgetRepository
                .GetAll()
                .Include(p => p.CreatorUser)
                .AsQueryable();

            var recordCount = await query.CountAsync();

            var records = await query
                .OrderBy(input.Sorting)
                .PageBy(input)
                .ToListAsync();

            var listDto = records.MapTo<List<WidgetListDto>>();

            return new PagedResultDto<WidgetListDto>(
                recordCount,
                listDto);

        }
[AutoMap(typeof(Widget))]
    public class WidgetListDto
    {
        public int Priority { get; set; }

        public string CreatorUserName { get; set; }

        public DateTime CreationTime { get; set; }

        [NotMapped]
        
        [ForeignKey("CreatorUserId")]
        public virtual User User { get; set; }

        public long CreatorUserId { get; set; }

        public string DisplayName

        {
            get

            {

                return User.UserName;
            }
        }
            }

        }
public class Widget : FullAuditedEntity<Guid, User>
 {
        [Required]
        public virtual int Priority { get; set; }
 }
Showing 1 to 1 of 1 entries