public partial class item
{
public int ItemId { get; set; }
// other properties....
public virtual ICollection itemdetails { get; set; }
public virtual itemImage itemImage { get; set; }
}
public partial class itemImage
{
//image properites...
}
public partial class itemdetail
{
public int itemdetailId { get; set; }
// other properties....
public int? ItemId { get; set; }
[JsonIgnore]
public virtual item item { get; set; }
public int? DimensionId { get; set; }
[JsonIgnore]
public virtual dimension dimension { get; set; }
}
public partial class dimension
{
public int DimensionId { get; set; }
// other properties....
public virtual itemdetail itemdetail { get; set; }
}
On this, I'm trying to update the DB by GraphDiff like below;
_context.UpdateGraph(_item, c => c
.OwnedEntity(x => x.itemImage)
.OwnedCollection(x => x.itemdetails,
with=>with.AssociatedEntity(z=>z.dimension))
);
This updates the record values to null with dimensionid which is equal to itemdetailsId
and if I change the with=>with.AssociatedEntity to with=>with.OwnedEntity (just for a check) it overwrites the same record with values. But It never creates a new record even if I have dimensionId is "0".
`Hi,
I have below scenario
public partial class item { public int ItemId { get; set; } // other properties....
public virtual ICollection itemdetails { get; set; }
public virtual itemImage itemImage { get; set; }
}
public partial class itemImage
{
//image properites...
}
public partial class itemdetail
{
public int itemdetailId { get; set; }
// other properties....
public int? ItemId { get; set; } [JsonIgnore] public virtual item item { get; set; }
public int? DimensionId { get; set; } [JsonIgnore] public virtual dimension dimension { get; set; } }
public partial class dimension { public int DimensionId { get; set; } // other properties.... public virtual itemdetail itemdetail { get; set; } }
On this, I'm trying to update the DB by GraphDiff like below; _context.UpdateGraph(_item, c => c .OwnedEntity(x => x.itemImage) .OwnedCollection(x => x.itemdetails, with=>with.AssociatedEntity(z=>z.dimension)) ); This updates the record values to null with dimensionid which is equal to itemdetailsId
and if I change the with=>with.AssociatedEntity to with=>with.OwnedEntity (just for a check) it overwrites the same record with values. But It never creates a new record even if I have dimensionId is "0".