views:

22

answers:

1

Hi all,

I'm wondering if this is feasible and how. I've an entity that is a simple 1 to 1 mapping against a database. I'd like to add a custom property to this entity that is the result of a stored procedure call. This SP returns a collection of the same entity (hierarchical data).

Any ideas?

Thanks in advance, Fabian

A: 

You could create a partial class with the same name and create a property that gets the collection. In the class have a private collection that you fill if empty in the get with a private function or just return it if the collection is already populated.

Mike
I can't do that because I don't (and I don't want to) have my database context inside my entity.
Fabian Vilers
Well then I think you might be out of luck. Hope someone proves me wrong! If you have the relationship set up int the db it would make the collection for you but I assume you have some special logic in your SP.
Mike