When trying to edit and save a record in an ajax call via javascript, I am getting the above subject error.
I did some looking up, and the only thing I can find was something about a "pareByIdentity" property which I couldn't get how to implement in my situation, if that's the case.
The below class is where there is a one to many relationship. There can be one "project" to many "timetrackings". This is the class for the "TimeTrackings" where the "ProjectID" is the foreign key.
I am using a WCF application to retrieve and edit the data with EF 6. This is the first time I'm encountering it in my application. Obviously, because of the way the relationship is set up.
Can someone please inform me how I can correct this error?
namespace YeagerTechDB.Models
{
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
[Serializable, DataContract(IsReference = true)]
public partial class TimeTracking
{
[Key]
[ScaffoldColumn(false)]
[Editable(false)]
[Display(Name = "Tracking ID")]
[DataMember]
public int TimeTrackingID { get; set; }
[Required]
[Display(Name = "Project ID")]
[DataMember]
public short ProjectID { get; set; }
[Required]
[DataType(DataType.Date)]
[DataMember]
public DateTime StartDate { get; set; }
[Required]
[DataType(DataType.Date)]
[DataMember]
public DateTime EndDate { get; set; }
[DataType(DataType.MultilineText)]
[DataMember]
public string Notes { get; set; }
[DataType(DataType.DateTime)]
[DataMember]
public DateTime CreatedDate { get; set; }
[DataType(DataType.DateTime)]
[DataMember]
public DateTime? UpdatedDate { get; set; }
[DataMember]
public virtual Project Project { get; set; }
}
}
The output of the debugging is below. Please copy the image and paste it to your favorite image viewer for better detail.
Notice that the value of the TimeTrackingID is set correctly to 1.
When trying to edit and save a record in an ajax call via javascript, I am getting the above subject error.
I did some looking up, and the only thing I can find was something about a "pareByIdentity" property which I couldn't get how to implement in my situation, if that's the case.
The below class is where there is a one to many relationship. There can be one "project" to many "timetrackings". This is the class for the "TimeTrackings" where the "ProjectID" is the foreign key.
I am using a WCF application to retrieve and edit the data with EF 6. This is the first time I'm encountering it in my application. Obviously, because of the way the relationship is set up.
Can someone please inform me how I can correct this error?
namespace YeagerTechDB.Models
{
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
[Serializable, DataContract(IsReference = true)]
public partial class TimeTracking
{
[Key]
[ScaffoldColumn(false)]
[Editable(false)]
[Display(Name = "Tracking ID")]
[DataMember]
public int TimeTrackingID { get; set; }
[Required]
[Display(Name = "Project ID")]
[DataMember]
public short ProjectID { get; set; }
[Required]
[DataType(DataType.Date)]
[DataMember]
public DateTime StartDate { get; set; }
[Required]
[DataType(DataType.Date)]
[DataMember]
public DateTime EndDate { get; set; }
[DataType(DataType.MultilineText)]
[DataMember]
public string Notes { get; set; }
[DataType(DataType.DateTime)]
[DataMember]
public DateTime CreatedDate { get; set; }
[DataType(DataType.DateTime)]
[DataMember]
public DateTime? UpdatedDate { get; set; }
[DataMember]
public virtual Project Project { get; set; }
}
}
The output of the debugging is below. Please copy the image and paste it to your favorite image viewer for better detail.
Notice that the value of the TimeTrackingID is set correctly to 1.
Share Improve this question asked Feb 16, 2015 at 16:23 sagesky36sagesky36 4,69220 gold badges86 silver badges134 bronze badges1 Answer
Reset to default 7The problem is ing from your JSON.stringify
in line 66.
You are converting the object Tracking_Input
to json.
Tracking_Input.TimeTrackingID
is a jquery array of dom elements with the id TimeTrackingID, and this cannot be converted to json.
Did you mean $('TimeTrackingID').val()
to match the other lines