Hi Team
I am using entity framework and have a property for Time as Timespan, somehow when i used Ado.Net entity model on local machine. autogenerated file for my model for this property was System.Timespan Time {get;set;}// This now currently not saving time as timespan and defaults with 00:00:00 from local database. Any reason for this?
// Model
public TimeSpan Time { get; set; } // This was public system.Timespan Time {get;set;}
// Controller
// Saving functionality
public ActionResult SaveIncidentTemplates(Incident_DropDown incident_templates)
{
if (ModelState.IsValid)
{
using (TimeLineApplicationDBContext db = new TimeLineApplicationDBContext())
{
Incident_Template template = new Incident_Template
{
Title = incident_templates.Title,
Date_Occured = incident_templates.Date.Date.ToString(),
Time = incident_templates.Date.TimeOfDay,
Description = incident_templates.Description,
Assignment_Group = incident_templates.Assignment_Group,
Reported_CI = incident_templates.Reported_CI
};
try
{
db.Incident_Template.Add(template);
db.SaveChanges();
}
catch(Exception ex)
{
}
}
}
return View();
}
// View
Sachin SinghPosted Nov 15, 2021, 9:34 AM
Srinivasan RamamoorthiPosted Nov 15, 2021, 9:23 AM
Srinivasan RamamoorthiPosted Nov 15, 2021, 9:17 AM
Guest UserPosted Nov 15, 2021, 9:14 AM
Srinivasan RamamoorthiPosted Nov 15, 2021, 9:09 AM
Did you debug and check if the controller gets the right value before saving?
Sachin SinghPosted Nov 15, 2021, 9:04 AM