Thanks Peter, that is a really good start in two ways... firstly gives me
the confidence to spend some time working it out, without feeling it may all
be for nought, and secondly the tips on improving the use of the find
method. Having said that the match criteria will be different between the
different lists, so I'm not sure that I can use a anonymous method or lambda
expression, but will consider it when I get that far in working out a
common approach.
One last thing, just to clarify the List<LocationInfoDTO> is part of the
EventDTO class structure and provides the raw data to instantiate a Event
class, which has a List<EventLocation>. EventLocation and LocationInfo DTO
map to each other. It is this mapping that I am trying to acheive in this
case.
Thanks for your help, I suspect that I shall be back for a little more, but
in the meantime I have enough to get me started.
Thanks, Richard
"Peter Duniho" <(E-Mail Removed)> wrote in message
news

(E-Mail Removed)...
On Wed, 02 Jul 2008 05:01:47 -0700, RichB <(E-Mail Removed)> wrote:
> [...]
> 1. Are my expectations correct, should I be able to create a generic
> helper method that does the tasks needed? [...]
>
> 2. If I should be able to produce a generic method, then where should I
> be looking for inspiration?
I don't know how to answer your second question. The answer to your first
question is probably "yes", but we don't really have enough information
about the classes to answer with authority. Looking at the code you
posted, it seems possible that "LocationInfoDTO" is a sub-class of
"EventLocation". If that's correct, then I would expect the code you
posted to be easily moved to a helper method, probably in a base class
shared by any objects that would use it.
By the way, you may also want to read up on anonymous methods and lambda
expressions. You appear to be using a member field to store state for
your predicate passed to Find(), but this can be addressed in a cleaner,
more readable fashion with an anonymous method or lambda expression. For
example, instead of:
listMatch = loList;
loc = this.locationList.Find(EventLocationListMatch);
(and of course, whatever the implementation of "EventLocationListMatch()"
is)
you could have:
loc = this.locationList.Find(lo => lo == loList);
or:
loc = this.locationList.Find(delegate(EventLocation lo) { return lo ==
loList; });
Pete