C# / Entity Framework / Linq question regarding calling a method when a class is accessed...

Posted by Daniel on Stack Overflow See other posts from Stack Overflow or by Daniel
Published on 2011-01-02T20:46:57Z Indexed on 2011/01/02 20:54 UTC
Read the original article Hit count: 210

Filed under:
|
|

So this is probably really basic, but I'm fairly new to all this. I am using Entity Framework with POCO entities. I want to call a method when a class property is set.

I am trying to build an advertisement platform. I have a Customer class, a Venue class and an Advertisement class. I have my indexes set up in such a way that I can call customer.venue. However, I want to be able to call Customer.Venue.CurrentAdvertisement and have it execute a method (if CurrentAdvertisement is null) and return the current advertisement. I know I can explicitly set it every time, but I want to be able to override my classes so that whenever the CurrentAdvertisement property is accessed via LINQ it runs that method to return an ad.

In order to do this I need to pass the Venue class a variable (venue name).

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about entity-framework