I have a List of objects and one of the properties on each object is a list of another objects. To support adding and editing, I have a SfGrid with a dialog edit and in the content of that dialog is a component. In that component, I have a SfGrid with inline editing and a toolbar. When clicking the Edit button it puts the row in edit mode. But when clicking the Update button, it does not take it out of edit mode. The Add works the same way. When I add an OnActionFailure event handler, I get the following message:
Unable to cast object of type 'System.Collections.Generic.HashSet`1[signify_custom.Data.Models.UserHistory]' to type 'System.Collections.IList'.
My objects are defined as follows (some properties removed for brevity:
public List<User> Users
public partial class User
{
[Key]
public int UserId { get; set; }
public string Email { get; set; }
public ICollection<UserHistory> UserHistories { get; set; }
}
public class UserHistory
{
public UserHistory() { }
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public int UserId { get; set; }
public string Type { get; set; }
[ForeignKey("UserId")]
public User User { get; set; }
}
The parent grid is bound to @Users. The component that is in the dialog edit of the parent grid passes the edited User record as a parameter called User. The child grid in the component is bound to @User.UserHistories.
The Id field of the child grid is defined as a primary key column:
<GridColumn Field=@nameof(UserHistory.Id) Visible="false" IsIdentity="true" IsPrimaryKey="true" />
What am I doing wrong?