how to add one extra temporary entity in collection returned by LINQ
here my code-
List<ReservationSlotLimitDetailEntity> sorted = (from p in slotLimitCollection.OfType<ReservationSlotLimitDetailEntity>()
where p.DayOfTheWeek == dayOfTheWeek
开发者_运维百科 select p).ToList<ReservationSlotLimitDetailEntity>();
I want to sort in such a way so that it will add on more temp column "DayName" based on condition such that if dayOfTheWeek==1 DayName=Monday
and if dayOfTheWeek==2 DayName=Tuesday
and so on.
- Add
string DayName
as a property of the ReservationSlotLimitDetailEntity class - Add a function
GetDayName(int dayOfTheWeek)
that translates dayOfTheWeek values into the text that you want (switch structure,case 1: return "Monday"
, etc. After you retrieve your data, do the following:
sorted.ForEach(x => x.DayName = GetDayName(dayOfTheWeek);
精彩评论