我只想使用 linq 显示日期我的编码是
var xyz = from xy in entity.TrainingDetails
join ede in entity.EmployeeDetails
on xy.TrainerId equals ede.id
join lmn in entity.Topics
on xy.TopicId equals lmn.id
where (xy.TrainerId == ede.id)
where (xy.TopicId == lmn.id)
select new
{
EmployeeId = ede.EmployeeId,
Trainer = ede.FirstName + ede.MiddleName + ede.LastName,
SINo = xy.Id,
TrainingDate = xy.TrainingDate,
StartTime = xy.StartTime,
EndTime = xy.EndTime
};
这是有效的。在我的输出中,日期显示在12-04-2013 00:00:00
这里我只想要12-04-2013
。我试过了
TrainingDate = String.Format("{0:MM/dd/yyyy}",xy.TrainingDate),
TrainingDate = xy.TrainingDate.ToString("dd/MM/yyyy"),
TrainingDate =xy.TrainingDate.ToString("d", DateTimeFormatInfo.InvariantInfo)
TrainingDate =xy.TrainingDate .Date
所有这些,但仍然没有得到。