In fact, the most useful goal of partial methods is for the code generation system to provide an API to extend the capabilities of its properties and methods without using inheritance.
Take a look at any Linq to SQL data model for a quick example.
The generated code includes partial methods, which, if implemented in your own partial class, provide the ability to execute validation logic, event notifications, etc. within existing properties.
What makes partial methods attractive is that if you don't implement them in your own partial class, they donβt get into compiled code at all, which provides a moderate increase in efficiency.
Here's a decent blog post that demonstrates the use of partial methods to introduce validation logic:
http://www.davidhayden.com/blog/dave/archive/2007/07/24/LINQToSQLValidationEnterpriseLibraryValidationApplicationBlock.aspx
source share