I am building a nuget
package that will be shared across many projects in the enterprise. It's essentially Entity Framework Model. At some point these classes were scaffolded from the database and the classes that were generated were all defined as partial (all examples are for illustration purposes only):
public partial class Customer { ... }
public partial class Order { ... }
Some projects took advantage of this partial
and developed additional functions that are beyond what database cares for:
public partial class Customer {
// get distance from the office to customer home
public decimal Distance { get { ... } }
}
Which allows using this calculated value in LINQ statements:
from c in Customer where Distance < 100 select c
But now that the "core" set of classes are in nuget package, the classes are no longer partial. Is there a way to force nuget to respect partial
attribute? I realize that it's too tight coupling; but it would greatly simplify transition from "embedded" model to nuget
In C# you can not take advantage of partial mechanic to split the definition of a class into different assembly.
Please see msdn explanation.
What about extensions ? Define your method in an extension class with your methods in the same namespace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With