pdevito3 / craftsman

A .NET scaffolding tool to help you stop worrying about boilerplate and focus on your business logic 🚀
https://wrapt.dev
MIT License
1.12k stars 65 forks source link

ForeignEntity property name is being generated with the entity name vs the name #90

Closed ogkushmin closed 2 years ago

ogkushmin commented 2 years ago

I have an entity defined with foreign entities, when the code is generated it is ignoring the property name and using the foreignentityname.

Steps to reproduce

-yaml

Output

using Ordering.Domain.Users; using Ordering.Domain.Users;

[Table("Advertiser")] public class Advertiser : BaseEntity { [Sieve(CanFilter = true, CanSort = true)] public virtual string Name { get; private set; }

[JsonIgnore]
[IgnoreDataMember]
[Sieve(CanFilter = true, CanSort = true)]
public virtual User User { get; private set; }

[JsonIgnore]
[IgnoreDataMember]
[Sieve(CanFilter = true, CanSort = true)]
public virtual User User { get; private set; }
pdevito3 commented 2 years ago

hmm, interesting. Will try and take a look at this later tonight!

pdevito3 commented 2 years ago

About to head out to an event, so can't dig in deep at the moment, but at first glance you might want to try something like this:

      - Name: CreatedById
        Type: Guid
        ForeignEntityName: User
        ForeignEntityPlural: Users
      - Name: ModifiedById
        Type: Guid
        ForeignEntityName: User
        ForeignEntityPlural: Users

If I'm remembering that part of the codebase correctly, it needs the Id property and will make the entity based on off of the given info automatically something like this with just the entity might not work at the moment. Can think though options to make things more flexible if that is the case though.

Even if the above does work you might need to make minor mods as it will probably add the User prop twice similar to what is already happening because there's no check to see if it's already there

pdevito3 commented 2 years ago

able to repro and yeah it shouldn't be happening that way. digging now!

pdevito3 commented 2 years ago

found it. thanks for the callout!