Sandeep Kumar

Sandeep Kumar

  • 1.1k
  • 683
  • 60.8k

Why Order By Creation Desc Not Working

Mar 24 2023 7:32 AM
var _NotifyData = (from Notification in _dbContext.Notification
          join MstStage in _dbContext.MstStage on Notification.Status equals MstStage.Id
          where Notification.DeptId == (DeptId == 0 ? Notification.DeptId : DeptId) && Notification.Status == (Items.Status == 100 ? Notification.Status : Items.Status)
           && Notification.CreatedOn >= (Items.FromDate == string.Empty ? Notification.CreatedOn : ApplicationData.AppStringToDatetime(Items.FromDate)) && Notification.CreatedOn <= (Items.ToDate == string.Empty ? Notification.CreatedOn : ApplicationData.AppStringToDatetime(Items.ToDate))
          orderby Notification.CreatedOn descending
          select new NotifyData
          {
              RefNId = Notification.RefNid,
              NType = Notification.Ntype,
              NotificationH = Notification.NotificationH,
              NotificationB = Notification.NotificationB,
              Comment = Notification.Comment,                                
              StatusId = (int)MstStage.Id,
             Status = MstStage.Mode,
              CreatedBy = (int)Notification.CreatedBy,
              CreatedOn = ApplicationData.AppDateToString(Notification.CreatedOn),
              ModifiedBy = (int)Notification.ModifiedBy,
              ModifiedOn = ApplicationData.AppDateToString(Notification.ModifiedOn)
          }).Distinct().AsEnumerable().Select((k, index) => new NotifyData()
          {
              SrlNo = index + 1,
              RefNId = k.RefNId,
              NType = k.NType,                          
              NotificationH = k.NotificationH,
              NotificationB = k.NotificationB,
              Comment = k.Comment,
              ApproveBy = k.ApproveBy,
              StatusId = k.StatusId,
              Status = k.Status,
              CreatedBy = k.CreatedBy,
              CreatedOn = k.CreatedOn,
              ModifiedBy = k.ModifiedBy,
              ModifiedOn = k.ModifiedOn,
              Can_Approve = GetRegistationResult(_authenticationManager.GetAuthenticatedUser().Result.UserId, UserManageAccess.NotificationPage, UserManageAccess.NotificationApproveAction).Result,
          }).ToList();

 


Answers (4)