我有一个问题,我的数据库中有一个时间跨度,我想在我的控制器中使用它,但是出现了这个错误
无法将类型“字符串”隐式转换为“System.TimeSpan”
控制器 :
int id = Convert.ToInt32(clientId);
clientShift = (from a in db.Client_Shift
where a.ID == id
select a).SingleOrDefault();
clientShift.DayFrom_LookID = Convert.ToInt32(dateFrom);
clientShift.DayTo_LookID = Convert.ToInt32(dateTo);
This is where the error occur --> clientShift.EndTime = endTime.Trim();
clientShift.DateModified = DateTime.UtcNow;
clientShift.ModifiedBy = User.Identity.Name;
模型 :
public partial class Client_Shift
{
public int ID { get; set; }
public int Client_ID { get; set; }
public int DayFrom_LookID { get; set; }
public int DayTo_LookID { get; set; }
public System.TimeSpan StartTime { get; set; }
public System.TimeSpan EndTime { get; set; }
感谢可以帮助我的人:D