views:

24

answers:

1

Hi .. I intend to extend the constructors of some of the entities in my Entity Framework (4).

However how do I ensure that my constructor is run after the model has run its. i.e. I want to ensure that the the object holds the data from the database before I work on it in my constructor.

A: 

Use constructor chaining.

Pavel Minaev
Thanks Pavel Constructor chaining I don't think will help.The entity framework creates :partial class ABC{ ABC() {}}I create :partial class ABC{ ABC() { do something here }}I want my constructor to be called after the entity framwork one .. so that the object is populated with data so I can 'do something here' with it ..
Adam
doesn't layout nicely in this comment area .. sorry
Adam
You can't do that, sorry. You can't have half of a method (or constructor) in one place, and another half of the same method (or constructor) in another place - it's not what partial classes/methods do.
Pavel Minaev
That said, I wonder where do those generated constructors come from in the first place. I just played with a simple EF4 project a little bit, and code generated for my entities did not have any explicitly declared constructors...
Pavel Minaev