Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Is there a easier way to map properties using automapper?

$
0
0

 public static void AddReservation(Member_ mem, Video_ video)
        {
            // populate the reservation object with data in the member and video
            // add to the database

            [b]Mapper.CreateMap<Video_,Reservation>().ForMember(m => m.Video_ID,c => c.MapFrom(e => e.ID));[/b]
            
            
            try
            {
                using( var a = new videoRentalEntities())
                {
                   Reservation currentReservation = ReservationMapping(mem,video);
                   a.Reservations.AddObject(currentReservation);
                    a.SaveChanges();

                }
            }
            catch
            {
                throw new ArgumentException();
            }
        }




its kind of tedious to map every single property from the business entity to dataobject, As i have 10 properties. By the way the properties are of different names from eachother, i'm aware of using the mapper.map() method.

So instead of mapping each property indivdual, times 10 is there a more easier way?

thanks,

Ray

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>