我使用LINQ
在几分钟(75)内从数据库中获取值。现在我想使用LINQ
将此分钟转换为HH MM SS格式。任何人都可以帮助我。
谢谢。 我尝试使用以下代码,但我没有成功。
TimeSpan tsMinutes;
try
{
using (VodafoneDataClassesDataContext vodafoneDataClassesDataContext = new VodafoneDataClassesDataContext())
{
vodafoneDataClassesDataContext.Connection.ConnectionString = BECommon.VodafoneConnectionString;
return (from auditFormsFilledMasters in vodafoneDataClassesDataContext.AuditFormsFilledMasters
join storeMasters in vodafoneDataClassesDataContext.StoreMasters
on auditFormsFilledMasters.StoreId equals storeMasters.Id
join deskMasters in vodafoneDataClassesDataContext.DeskMasters
on auditFormsFilledMasters.DeskId equals deskMasters.Id
join usersMasters in vodafoneDataClassesDataContext.UserMasters
on auditFormsFilledMasters.AuditorId equals usersMasters.Id into tempMaster
from TempCircleStore in tempMaster.DefaultIfEmpty()
where auditFormsFilledMasters.StoreId == fieldStoreId
select new BEAuditFormsFilledMaster
{
minutesSpan = new TimeSpan(0, Convert.ToInt32(auditFormsFilledMasters.LengthofRecordinMin.ToString()), 0),
tsMinutes = new TimeSpan(0, Convert.ToInt32(auditFormsFilledMasters.LengthofRecordinMin.ToString()), 0),
LengthofConversation = auditFormsFilledMasters.LengthofRecordinMin.ToString(),
where auditFormsFilledValues.AuditFormsFilledMasterId == auditFormsFilledMasters.Id
select auditFormsFilledValues.SelectedScore).Sum(),
}).ToList<BEAuditFormsFilledMaster>().AsReadOnly();
}
答案 0 :(得分:4)
您需要做的是使用TimeSpan.FromMinutes
函数和重载的ToString
函数:
TimeSpan.FromMinutes(theAmountOfMinutes).ToString(@"hh\:mm\:ss:")