C# を使用した linq クエリがあり、変更されたフィールドで並べ替えたいと考えています。このフィールドは、テーブルで YYYYMM として定義されている部分的な日付フィールドです。ただし、リピーターにMM/YYYYとして表示したいのですが、YYYYMMとしてソートする必要があります。以下はコードで、GrantMonthID は問題のフィールドです。リピーターはMM/YYYYの順番でデータを表示します。
ありがとうございました。
var linqQuery = from nn in grantsReceivedDetailList
where (nn.ArrearAuditID == Convert.ToInt32(AdminBasePage.ArrearAuditId))
select
new
{
nn.GrantsReceivedID,
nn.PayeeMPINumber,
Firstname = participantRepository.GetParticipantDetailsbyMemberParticipantIndex(Convert.ToInt32(nn.PayeeMPINumber)).FirstName + " " +
participantRepository.GetParticipantDetailsbyMemberParticipantIndex(Convert.ToInt32(nn.PayeeMPINumber)).LastName,
nn.IVANumber,
GrantMonthID = nn.GrantMonthID.ToString().Substring(4, 2) + "/" + nn.GrantMonthID.ToString().Substring(0, 4),
nn.GrantAmount,
nn.Comments
};
linqQuery = linqQuery.OrderByDescending(y => y.GrantMonthID);
// Execute the linq query and databind
grantListRepeater.DataSource = linqQuery;
grantListRepeater.DataBind();