I have following object, it works fine when I specify standart objects like int, string and not with custom object.
[DataContract(Namespace = "")]
public class StatusLog<TItem>
{
/// <summary>
/// Gets or sets the key.
/// </summary>
/// <value>
/// The key.
/// </value>
[DataMember]
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the action status.
/// </summary>
/// <value>
/// The action status.
/// </value>
[DataMember]
public ActionStatus ActionStatus { get; set; }
/// <summary>
/// Gets or sets the object.
/// </summary>
/// <value>
/// The object.
/// </value>
[DataMember]
public TItem Object { get; set; }
/// <summary>
/// Gets or sets the message.
/// </summary>
/// <value>
/// The message.
/// </value>
[DataMember]
public string Message { get; set; }
}
This works:
return new StatusLog { Id = Guid.NewGuid(), ActionStatus = ActionStatus.Deleted, Object = Convert.ToInt32(id), Message = “Node deleted successfully” };
This does not work:
new StatusLog {Id = Guid.NewGuid(), ActionStatus = ActionStatus.Created, Object = MyCustomObject};
Have a look at KnownType Attribute.