thank you for your prompt response, after writing my post and having some time to mull things over I have found my answer, however I think I've uncovered a flaw in how Radzen handles this scenario.
(I'm using a Master/Detail DataGrid for clarity. My project uses a Master/Detail Hierarchy, which has some bearing on my error but not the underlying issue)
To recap above the StockItemsProductList table has two foreign keys to the Product table, correctly identified here in this excerpt from the DBContext.cs file
builder.Entity<EnergyCentre2.Models.EnergyOracle.StockItemProductList>()
.HasOne(i => i.Product1)
.WithMany(i => i.StockItemProductLists)
.HasForeignKey(i => i.Product)
.HasPrincipalKey(i => i.Id);
builder.Entity<EnergyCentre2.Models.EnergyOracle.StockItemProductList>()
.HasOne(i => i.Product2)
.WithMany(i => i.StockItemProductLists1)
.HasForeignKey(i => i.StockPart2)
.HasPrincipalKey(i => i.Id);
which exposes two separate collections of StockItemProductList from the Product table as shown in this excerpt from Product.cs
public ICollection<StockItemProductList> StockItemProductLists { get; set; }
public ICollection<StockItemProductList> StockItemProductLists1 { get; set; }
so far so good, however when building a master detail page from this data like this (notice the child collections 'StockItemProductLists' and 'StockItemProductLists1')
the resultant screen is broken as shown (Edited for brevity)
the reason for this is that while the first table is constructed correctly, the second uses the same query and assignment as shown.
protected async System.Threading.Tasks.Task Grid0RowSelect(EnergyCentre2.Models.EnergyOracle.Product args)
{
master = args;
if (args == null) {
StockItemProductLists = null;
}
if (args != null)
{
var energyOracleGetStockItemProductListsResult = await EnergyOracle.GetStockItemProductLists($"i => i.Product == {args.Id}", int.Parse($"{}"), int.Parse($"{}"));
StockItemProductLists = energyOracleGetStockItemProductListsResult;
}
if (args != null)
{
var energyOracleGetStockItemProductListsResult0 = await EnergyOracle.GetStockItemProductLists($"i => *i.Product* == {args.Id}", int.Parse($"{}"), int.Parse($"{}"));
*StockItemProductLists* = energyOracleGetStockItemProductListsResult0;
}
}
when it should look like this
protected async System.Threading.Tasks.Task Grid0RowSelect(EnergyCentre2.Models.EnergyOracle.Product args)
{
master = args;
if (args == null) {
StockItemProductLists = null;
}
if (args != null)
{
var energyOracleGetStockItemProductListsResult = await EnergyOracle.GetStockItemProductLists(new Query() { Filter = $@"i => i.Product == {args.Id}" });
StockItemProductLists = energyOracleGetStockItemProductListsResult;
}
if (args != null)
{
var energyOracleGetStockItemProductListsResult0 = await EnergyOracle.GetStockItemProductLists(new Query() { Filter = $@"i => *i.StockPart2* == {args.Id}" });
*StockItemProductLists1* = energyOracleGetStockItemProductListsResult0;
}
}
The differences have been are shown between asterisks.
Whether or not StockItemProductLists is loaded, the collection StockItemProductLists1 always uses the connection to StockItemProductLists even though the underlying code seems to know the difference.
My original issue was caused by an incomplete fix where I corrected the query to fetch the correct data but didn't fix the assignment so I had, from the application point of view, changed the StockItemProductLists collection(I was using a Hierarchy view so {event}.StockItemProductLists recieved the data for {event}.StockItemProductLists1) hence the error.
So now I know what I was doing wrong, is it possible to fix Radzen to correctly identify the correct collection? (Maybe there's not enough information exposed in the database .cs files to adequately infer the correct connection?)
thank you again, and sorry for the long post
Ian