Code Monkey home page Code Monkey logo

Comments (17)

ErikEJ avatar ErikEJ commented on July 21, 2024

Generally, generating DTOs directly from the database is not a good pattern, IMHO.

Are you referring to just the file names?

from efcorepowertools.

yomer avatar yomer commented on July 21, 2024

Yes, just the the file names.

I understand that that's not a best pattern. I'm trying to use it as a head start for my DTOs. Then use the nav properties as a reference to flatten and alter my DTOs manually.

Maybe this is a different scope or already doable through handlebars, but it would be great to use the template to go through the nav properties and generate composed name properties derived from themdirectly in the main class, like automapper does.

from efcorepowertools.

kachalkov avatar kachalkov commented on July 21, 2024

We found that handlebars are not as easy to modify especially for suffix, end up using GeCo (Generator Console) for that:

https://github.com/iQuarc/Geco

from efcorepowertools.

yomer avatar yomer commented on July 21, 2024

Can't this be added via the GUI interface, to add the suffix to the filename?

from efcorepowertools.

ErikEJ avatar ErikEJ commented on July 21, 2024

@yomer How would that affect the class Name? Or are you referring to just the file name?

from efcorepowertools.

yomer avatar yomer commented on July 21, 2024

It's just for the file name. The class Name, I can set it by modifying the handlebar templates. I was looking into adding a suffix for the sake of having the class Names and filenames with the same suffix.

I know that my request is a bit specific. Maybe someone else could eventually need to add either a prefix or a suffix to their classes.

A small reminder: I'm using EF CorePowerTools to generate my model for data access. And, since I would have to type in a lot of code to make my DTOs, my intention is to use this tool to generate suffixed classes (and filenames) which then I will alter to end up with said DTOs.

from efcorepowertools.

r3faat1 avatar r3faat1 commented on July 21, 2024

I made an issue about this but I closed it since this already exist. I also would like to see something exactly the same as what the OP is requesting. Being able to add suffix to filename only. This was my message:

I think it would be a good idea to implement a way we can add prefix/suffix to generated classes from table. Let's say we have a "Blogs" table. When I run the power tool, it'll generate "Blog" class. However, in my project I already have a "Blog" class as well. Sure, I can easily reference the correct namespace and do ToPOCO conversion. However, it'll be much easier to differentiate if I could add suffix to my generated class name, something like "BlogDTO" or "BlogEF". Maybe an option, where we can pick the generated classnaming? E.g. "{class}DTO". My closed issue: #75

from efcorepowertools.

r3faat1 avatar r3faat1 commented on July 21, 2024

Any update on this? It's a big help because you can have 3 different types of class with the same name. For example, Blogs (local class), Blogs (Database/EF Class), and Blogs (DTO Class). So if we can add a suffix like "BlogsDBO", it can help in differentiating which class we are looking for. It's hard to do this manually when you might have over 100 classes generated by EF PowerTools

from efcorepowertools.

ErikEJ avatar ErikEJ commented on July 21, 2024

@refx32 You could put the files in different name spaces and/or projects - having them all in the same folder seems like a wrong pattern

from efcorepowertools.

r3faat1 avatar r3faat1 commented on July 21, 2024

@ErikEJ Yes, of course. That is exactly how we have it (Different folders, different projects). But now imagine I'm making a new file, and I'm calling "Blogs" class. When I press "CTRL + ." to generate the namespace, I have to pick between the 3 namespace (.DTO, .DBO, or .Model).

Even worse, let's say I'm debugging old files, at the first glance, I don't know which "Blogs" it is. I have to hover over to see the proper namespace of "Blogs". Vs. if it was "BlogsDTO" or "BlogsDBO", I know exactly what it is just by a quick glance.

from efcorepowertools.

ErikEJ avatar ErikEJ commented on July 21, 2024

@refx32 Some users in this thread are referring to just the file names, but if I understand you correctly, you are referring to the class names - so there are two issues here? Or am I misunderstanding?

from efcorepowertools.

ErikEJ avatar ErikEJ commented on July 21, 2024

Modifying the file names is just a question about getting the required input about what to do, and the modify the code here: https://github.com/ErikEJ/EFCorePowerTools/blob/master/src/GUI/EFCorePowerTools/Handlers/ReverseEngineerHandler.cs#L186

from efcorepowertools.

r3faat1 avatar r3faat1 commented on July 21, 2024

Sorry, I was not aware people were referring to file names. Why have a file name different than class name though? If they create a file name like "BlogsDTO.cs", why have a class name like "Blogs" inside it? This does not feel clean to me.

One of the suggestion was having a "Suffix/Prefix input" when the option pops up. It could be "{tableName}" by default, and if we want to add any suffix/prefix to it, we can change it to something like "{tableName}DBO", which will generate "Blogs" table name as "BlogsDBO". Once again, just a suggestion.

from efcorepowertools.

ErikEJ avatar ErikEJ commented on July 21, 2024

@refx32 I think this feature will be able to help you: #128 (comment)

from efcorepowertools.

r3faat1 avatar r3faat1 commented on July 21, 2024

So that is kind of like a configuration file? We have over 100 tables at our work, is there a way I can define every class we generate, we want it named {tableName}DBO on that file?

from efcorepowertools.

ErikEJ avatar ErikEJ commented on July 21, 2024

How you create and maintain the file is entirely up to you and your imagination.

from efcorepowertools.

dharmaturtle avatar dharmaturtle commented on July 21, 2024

I accomplished OP's request here: TrackableEntities/EntityFrameworkCore.Scaffolding.Handlebars#34 (comment)

from efcorepowertools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.