Open Closed

Relate a child entity more than once to the master #8324


User avatar
0
mguerra created
  • ABP Framework version: v8.3.4
  • UI Type: MVC / Razor
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Steps to reproduce the issue:

I have an Entity called Product with PK <Guid> and a child entity called ProductBundle that relates to the Master through the PK. The ProductBundle entity will contain the products that will be part of the Product (master) package, that is, a product may be composed for several other products from the same entity. How would you solve this dilemma through the abp suite?


7 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Sorry, I don't quite understand.

  • User Avatar
    0
    mguerra created

    Well, I'll try to explain again. I have a table that contains products (master) and a child table that contains information about which products will make up this product, that is, a product can be formed by a set of other products in the master table. So the ProductsBundle child table is related to the master table through the Id. So far, nothing new, but I also need to allow a relationship between the child table through the ProdutoIdBundle field with the Id of the Products table. Normally in SQL server we create a relationship with this table by assigning an alias to it, thus allowing the child table to maintain two distinct relationships with the parent table.

    Select P.Descricao as Root, P1.Descricao as Child from appProdutoBundles B inner join appProdutos P on B.produtoId=P.Id left outer join appProdutos P1 on B.ProdutoIdBundle=P1.Id

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I think there is no problem, you can use suite advanced tab to add navigation Property

  • User Avatar
    0
    mguerra created

    Hi,

    Unfortunately it doesn't work, as the ProdutoBundle entity is a child of Produto.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    After my check ,this is the limitation of the suite. you need to do this manually.

  • User Avatar
    0
    mguerra created

    Could you give me an example, so that regeneration through ABP Suite does not overwrite?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I think you better manually write code instead of using suite for this case

Made with ❤️ on ABP v9.2.0-preview. Updated on January 08, 2025, 14:09