EasyAbp / AbpHelper.CLI

Providing code generation and more features to help you develop applications and modules with the ABP framework.
MIT License
285 stars 95 forks source link

AggregateRoot with nested Entity #143

Open Climax85 opened 3 years ago

Climax85 commented 3 years ago

For example, there is a Blog AggregateRoot with a list property of Posts:

public class Blog : AggregateRoot<Guid>
{
    public virtual string Title { get; protected set; }

    public virtual List<Post> Posts { get; protected set; }
}

public class Post : Entity<Guid>
{
    public virtual string Title { get; protected set; }

    public virtual string Content { get; protected set; }
}

When I generate the code for Blog, I would expect that a BlogDto and a PostDto would be generated. Where the BlogDto contains a List of PostDto.

But what I get is just a BlogDto with a property of type List instead of List.

Would it be possible to support nested entities?

wakuflair commented 3 years ago

Unfortunately, that's not supported yet.

Climax85 commented 3 years ago

Thank you for the fast reply. Is this task in your roadmap? Could you give advise where and how to implement that on my own? Should be some recursive function. But I'm not familiar with elsa workflow yet. So I'm not sure where to implement that. There should probably be a list of EntityInfo?!

wakuflair commented 3 years ago

Hi @Climax85

Is this task in your roadmap

Not for recent plan.

Could you give advise where and how to implement that on my own?

I think it's possible to implement this through Roslyn service, which is already used to parse entity classes. It's not very related with elsa, although everything in ABPHelper is implemented as an elsa workflow. For now entity properties are parsed as strings, for your feature, they should be parsed with more info rather than a simple string.

You might need a pre scan of all entity types.

A little bit trivial, but possible.