Results 1 to 13 of 13
Feb 27, 2011, 17:38 #1
- Join Date
- Feb 2006
- 0 Post(s)
- 0 Thread(s)
Practical technique for dealing with null entities?
In my new ASP.NET EF4 project, I find myself having to do a lot of maneuvering around null entities. For example, I may have a Project Entity with a related User Entity exposed through an Assignee property. If, for example, I need to send an email to someone indicating who the Assignee is, I need to say:
string x = "The Assignee is: " + TheProject.Assignee.Name;
string x = "The Assignee is: " + TheProject.Assignee == null ? "", TheProject.Assignee.Name
I also realize I can build a helper method, or an extension method (loving these!) but I'd have to hard code for the .Name property, which isn't always what I want. I also want to avoid doing a whole bunch of reflection.