I have code something like this in an IRepository implementation in Linq to Sql:
var newlist = from h in list where h.StringProp1 == "1"
select new MyBusinessBO{
firstProp = h.StringProp1,
secondProp = h.StringProp2
};
The projection into MyBusinessBO is not difificult but when the Business Object has many properties the projection code becomes very lengthy. Also, as the projection can occur in several places in the Repository we break the DRY principle.
Is there any way to abstract out the projection or replace it with a delegate?
I.e. replace the code
firstProp = h.StringProp1,
secondProp = h.StringProp2
with something reusable?