简体   繁体   English

如何正确地将注释添加到生成的类属性?

[英]How to properly add comments to generated class properties?

I have some classes generated by EF out of an Oracle database. 我有一些由EF从Oracle数据库生成的类。 Those class will be used to build a restful Web API with Help Pages . 这些类将用于通过“ 帮助页面”构建一个宁静的Web API。 I wonder how do I add comments to the properties for those generated classes. 我想知道如何为这些生成的类的属性添加注释。 I can edit those generated class files, but if I have to remap them, they'll be gone. 我可以编辑那些生成的类文件,但是如果我必须重新映射它们,它们将消失。

I tried creating DTO classes for the generated classes and use AutoMapper , but that quickly go out of hand since I have so many classes to create DTO for, and the worse is that the derived class will end up with two properties and that makes the Help Page not very helpful. 我尝试为生成的类创建DTO类并使用AutoMapper ,但是由于要创建DTO的类太多了,所以这种方法很快就失控了,更糟糕的是,派生类将最终具有两个属性,这使得Help页面不是很有帮助。

I hope C# lets me to redefine a property of a class, but I know that's not possible, I wonder what's the least painful way to add comments to generated classes. 我希望C#可以让我重新定义类的属性,但是我知道这是不可能的,我想知道向生成的类添加注释的最简单的方法是什么。

You don't need to place comments in code: it can be done in an XML file. 您无需在代码中放置注释:可以在XML文件中完成。

This is an old MSDN article , but check the resulting XML document at the bottom of the article. 这是MSDN上的旧文章 ,但请在文章底部检查生成的XML文档。

That is, you can create your own XML document and distribute it along with your assemblies as auto-generated ones. 也就是说,您可以创建自己的XML文档,并将其与程序集一起分发为自动生成的XML文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM