Dear All,
I have a List and i'm appling GroupBy, Orderby & ThenBy using LINQ-C#.
When i change the requestDate and remarks i'm getting the following erro.
At least one object must implement IComparable.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: At least one object must implement IComparable.
What I have tried:
IEnumerable<CandidateRefundVoucherInfo> requestVouchers = CandidateRefundVoucherController.Instance.GetByCenterID(16);
if (requestVouchers.Count() > 0)
{
var CandidateRefundVouchers = requestVouchers.
Select(items => new
{
CertificateID = items.Certificate.ID,
items.Certificate.Code,
items.Certificate.NameEN,
items.Certificate.NameAR,
items.Remarks,
items.RequestDate,
items.NumberOfRefundVoucherRequest,
items.StatusType,
UpdatedByUser = items.UpdatedByUser.NameEN
}).
GroupBy(i => new
{
i.CertificateID,
i.Code,
i.NameEN,
i.NameAR,
i.Remarks,
i.RequestDate,
i.NumberOfRefundVoucherRequest,
i.StatusType,
i.UpdatedByUser
})
.OrderByDescending(d => new { d.Key.RequestDate })
.ThenBy(l => new { l.Key.Remarks })
.Select(item => new
{
ID = item.Key.CertificateID,
Code = item.Key.Code,
NameEN = item.Key.NameEN,
NameAR = item.Key.NameAR,
RequestedVouchers = item.Sum(items => items.NumberOfRefundVoucherRequest),
Status = item.Key.StatusType,
RequestedDate = item.Key.RequestDate.ToString("dddd, dd MMMM yyyy"),
Remarks = item.Key.Remarks,
UpdatedBy = item.Key.UpdatedByUser,
BindLink = BindCode(item.Key.CertificateID, item.Key.Code)
});
rptCandidateRefundVouchers.DataSource = CandidateRefundVouchers;
rptCandidateRefundVouchers.DataBind();
Can anyone please help me.
Thanks