Byte array conversion throw System.NotSupported Exception

瀏覽次數:6 次
跳到第一則未讀訊息

atul2...@gmail.com

未讀,
2016年7月6日 清晨5:57:582016/7/6
收件者:AutoMapper-users

In Entityframework code first I have classes with timestamp field to maintain coincurrency when I am trying to retrieve data without AuotMapper mapping it work fibe but when I try to use mapping then it produce System.NotSupported Exception in my output window. My mapping code is below

Mapper.Initialize(cfg =>
            {
                cfg.CreateMap<ClientPhone, ClientPhoneViewModel>();
                cfg.CreateMap<ClientRecord, ClientRecordViewModel>();
            });

            Mapper.Map<ClientPhone, ClientPhoneViewModel>(new ClientPhone());
            Mapper.Map<ClientRecord, ClientRecordViewModel>(new ClientRecord());

//My viewmodel classess
public abstract class BaseViewModel
    {
        public int Id { get; set; }
        public byte[] RowVersion { get; set; }

    }

 public class ClientRecordViewModel : BaseViewModel
    {
        public string Name { get; set; }
        public string Address { get; set; }

        public ICollection<ClientPhoneViewModel> ClientPhones { get; set; }
    }

 public class ClientPhoneViewModel:BaseViewModel
    {
        public string ClientRecordName { get; set; }
        public string PhoneNumberNumber { get; set; }

        public int ClientRecordId { get; set; }

        public int PhoneNumberId { get; set; }

    }



my query to access it which throws an exception
` sdUow.ClientRecords.GetAll().ProjectTo<ClientRecordViewModel>().ToList();`

If i remove  RowVersion from baseviewmodel it works then

回覆所有人
回覆作者
轉寄
0 則新訊息