- ABP Framework version: v9.0.4
- UI Type: Blazor Server
- Database System: EF Core (PostgreSQL)
We cannot write a query like “var list = await context.Products.Include(x=> x.VariantCards).ToListAsync();”.
When we want to use include in list retrieval, we realized that there are no connections in the entity class opened by abp studio. I want to go through the example to make the problem more understandable.
I have 2 tables in the form of Product and VariantCard. There is a 1-n relationship between these tables. Product has multiple VariantCards and VariantCard has one Product.
But in the entity class opened by Abp Studio, there is no VariantCard list in Product. Because of this, a code like “var list = await context.Products.Include(x=> x.VariantCards).ToListAsync();” cannot be written. Because there are no “VariantCards”.
Even if you manually add “ICollection<VariantCard> VariantCard” to the Product class, you still cannot use the Include query because this connection is not specified in the settings in the context class of the project. You also need to add to the context class.
In my Repository class, I need to make a lot of manual additions and follow them to write “var list = await context.Products.Include(x=> x.VariantCards).ToListAsync();”. Moreover, when I update a class using abp studio's interface, the changes I made in the context class are deleted. This is a big problem.
Is there an easy way to make a query like this? We want to be able to use the query “var list = await context.Products.Include(x=> x.VariantCards).ToListAsync();”.
1 Answer(s)
-
0
Hello,
Unfortunately, ABP Suite does not currently support this feature. However, you can extend and add it via the code generated by the Suite. If you want your own code not to be overwritten by ABP Suite afterwards, you need to select the checkbox in the picture below and write your code to the extended classes accordingly. See more: https://abp.io/docs/latest/suite/customizing-the-generated-code