Reputation: 691
my code is
var model = dt.FishEventScheduleVaccination
.Join(
dt.FishEventSchedule,
vaccination => vaccination.ScheduleId,
schedule => schedule.ScheduleId,
(vaccination, schedule) => new { vaccination, schedule }
)
.Select(q=>new {
q.vaccination,
q.schedule
})
.Where(w=>w.schedule.Start>DateTime.Now).ToList();
var rtn=new List<FishEventScheduleVaccination>();
foreach (var m in model) {
var item = m.vaccination;
item.FishEventSchedule = m.schedule;
rtn.Add(item);
}
i want do with only lambda query, not foreach. how can i do? Is it possible?
Upvotes: 0
Views: 4127
Reputation: 3875
from r in Entities.tbl join q in Entities.tbl on r.Id equals q.Id2 select new
{
Id = r.Column + " " + r.Column, Data = q.Column + " " + q.Column
};
I think this should solve your Query
OR
you can also try something like this:
db.DTOPageSets.Join(db.DTOPageSets
.AsEnumerable(), a => a.ContentPageID, b => b.CategoryID, (a, b) => a);
Upvotes: 1
Reputation: 49095
Try this instead:
dt.FishEventScheduleVaccination
.Join(dt.FishEventSchedule,
vaccination => vaccination.ScheduleId,
schedule => schedule.ScheduleId,
(vaccination, schedule) => new { vaccination, schedule })
.Where(w => w.schedule.Start > DateTime.Now)
.AsEnumerable()
.Select(q => { q.vaccination.FishEventSchedule = q.schedule; return q.vaccination; })
.ToList();
Upvotes: 1