Reputation: 9
I am getting a value from database in minutes(75) using LINQ
. Now I want to convert this minutes into HH MM SS format using LINQ
. Can any one please help me.
Thank you. I tried with the following code, but I was unsuccessful.
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();
}
Upvotes: 0
Views: 2306
Reputation: 22794
What you need to do is use the TimeSpan.FromMinutes
function, and the overloaded ToString
function:
TimeSpan.FromMinutes(theAmountOfMinutes).ToString(@"hh\:mm\:ss:")
Upvotes: 4