我想保存我的编辑到数据库,我在ASP.NET MVC 3/C#中使用实体框架代码优先,但我收到错误.在我的Event类中,我有DateTime和TimeSpan数据类型,但在我的数据库中,我分别有日期和时间.这可能是原因吗?在保存对数据库的更改之前,如何在代码中转换为适当的数据类型.
public class Event
{
public int EventId { get; set; }
public int CategoryId { get; set; }
public int PlaceId { get; set; }
public string Title { get; set; }
public decimal Price { get; set; }
public DateTime EventDate { get; set; }
public TimeSpan StartTime { get; set; }
public TimeSpan EndTime { get; set; }
public string Description { get; set; }
public string EventPlaceUrl { get; set; }
public Category Category …Run Code Online (Sandbox Code Playgroud)