Partial Classes in C#

后端 未结 20 2809
广开言路
广开言路 2021-02-19 08:25

Are there are good uses of Partial Classes outside the webforms/winforms generated code scenarios? Or is this feature basically to support that?

20条回答
  •  臣服心动
    2021-02-19 08:55

    I use it in a data access layer. The generated classes like the mapper and queries a partial. If I need to add a mapper method for example to do a fancy load that's not generated I add it to the custom class.

    At the end the programmer that uses the data layer in the business layer only sees one class with all the functionality he or she needs. And if the data source changes the generic parts can easily be generated without overwriting custom stuff.

提交回复
热议问题