从对象生成 DTO

发布于 2024-07-19 05:57:32 字数 128 浏览 5 评论 0原文

我想从我现有的一些对象中自动生成一些 DTO,我想知道是否已经存在可以使用的 Resharper、DevExpress 或 VSX 开源工具,我需要一个工具来查看我的代码并让我选择我想要的属性包含在我的 DTO 中,然后基于该生成一个类...

I want to auto gen some DTOs from some of my existing objects, I was wondering if there already exist a Resharper, DevExpress or VSX open source to use, I need a tool to look into my code and let me choose which properties I want to include in my DTO and then generate a class based on that...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暮光沉寂 2024-07-26 05:57:32

另一种意见是在 T4 模板中使用一些反射代码。

T4 模板是 Visual Studio 强大的隐藏功能之一。

看看这里< /a> 来看看 T4 上手有多么容易。

Another opinion would be to use some reflection code in a T4 template.

T4 templates are one of the powerful hidden features of Visual Studio.

Take a look here to see how easy it is to get started with T4.

最好是你 2024-07-26 05:57:32

这是一种 hack,但您可以使用 Visual Studio/Resharper 从类中提取接口,然后创建 DTO 类并从接口派生,然后使用 Visual Studio 自动实现接口成员(然后,可以选择删除接口)。

This is kind of a hack but you could use Visual Studio/Resharper to Extract an interface from the class, then create a DTO class and derive from the interface, then use Visual Studio to auto implement the interface members (then, optionally remove the interface).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文