Populating entity with optional properties
-
Hello to all, I'm having kind of an issue with populating my entities. I have a Data Access for appointments. One time I will call a stored procedure returning me only the id, time and length of the appointment. Another time I will also receive the customer and the threatments of the appointment. (Sort of an agenda/customers overview for a Pet Barber..) I use a RunStoredProcedure method, to wich a pass the sp and the parameters. This method uses an SqlDataReader and returns a collection of appointments (in this case). In the method, to populate the entity, I use a PopulateEntity method, and that's where things go wrong. Since I'm not always populating the same number of properties, I sometimes call columns in the datareader that aren't there. Now, I could solve this, checking for a null value in the PopulateEntity method, but I'd rather have a more dynamic solution in wich I can pass the Properties to fill, and their respective column. Any nice way to do this? Can I pass object-properties by using attributes? Or am I on a wrong track here? Any help is welcome, tnx