I have a doubt about automapper's functioning..
we have a Function import returning a table say t_MyTable
t_MyTable is
ID ----- ForeignID ----- Data
where is ForeignID is id from other table and we have foreign key setup on this column.
so the result set returned by ef contains all ID, ForeignID and Data also I can see reference to t_Foreign table returned to which ForeignID belongs.
We use autoMapper to map from ef result to our entities..
CreateMap(Of t_MyTable , Concrete.Entities.MyTable)()
and to populate object Foreign we have to do this..
CreateMap(Of t_MyTable , Concrete.Entities.MyTable)().
ForMember(Function(d) d.Foreign, Sub(o) o.MapFrom(Function(e) Mapper.Map(Of t_Foreign, Foreign)(e.t_Foreign)))
this ofcourse is very slow as there are lots of foreign keys and lots of rows. I think there must be a way to tell ef the relation implicitly so that this can be made faster.
Any guidance around this will be appreciated.
Aucun commentaire:
Enregistrer un commentaire