question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error Mappin Expression type

See original GitHub issue

Source/destination types

public Expression<Func<TModel, bool>> ToModelExpression(Expression<Func<TViewModel, bool>> expression)
        {
            var cfg = _autoMaperConfiguration.Configuration().CreateMapper();
            var exp = cfg.Map<Expression<Func<TViewModel, bool>>, Expression<Func<TModel, bool>>>(expression);
            return exp;
        }

Mapping configuration

// Mapper.Initialize or just the CreateMap snippet 

Version: x.y.z

Version 7.0.1

Expected behavior

i want map

Actual behavior

i use top code to map expression type. but occured this error :

ParameterExpression of type ‘Co.Domino.Service.Account.ViewModel.AccountViewModel’ cannot be used for delegate parameter of type ‘Co.Domino.Model.Account.AccountModel’

Automapper return this :

.Lambda #Lambda1<System.Func`2[Co.Domino.Model.Account.AccountModel,System.Boolean]>(Co.Domino.Service.Account.ViewModel.AccountViewModel $m) { (System.Int32)($m.AccountGroup).AccountType == (System.Int32).Constant<Co.Domino.WinUI.Windows.Invoice.PageViewInvoices>(Co.Domino.WinUI.Windows.Invoice.PageViewInvoices)._selectedtAccountType && .Call ($m.Name).Contains(.Constant<Co.Domino.WinUI.Windows.Invoice.PageViewInvoices>(Co.Domino.WinUI.Windows.Invoice.PageViewInvoices)._filter) }

why still lambda parameters is AccountModel!!!

AccountModel and AccountViewModel

 public class AccountModel : BaseModel<int>
    {
        public string Name { get; set; }

        public int? AccountGroupId { get; set; }

        public double Cutie { get; set; }

        public string Tell { get; set; }

        public string Mobile { get; set; }

        public string Fax { get; set; }

        public double GoldCredit { get; set; }

        public int AmountCredit { get; set; }

        public int RefundPeriode { get; set; }

        public DateTime? Birthdate { get; set; }

        public DateTime? DateOfMarriage { get; set; }

        public string CloseFriend { get; set; }

        public bool CalculateVAT { get; set; }

        public string NationalCode { get; set; }

        public string ZipCode { get; set; }

        public string Address { get; set; }

        public DateTime? OpeningDate { get; set; }

        public InvoiceType InvoiceType { get; set; }

        public bool IsActiveAccount {get;set;}

        public string Description { get; set; }

        public string BranchName { get; set; }

        public string BankAccountNumber { get; set; }
    
        public BankAccountType BankAccountType { get; set; }

        public string BankAccountOwner { get; set; }

        public double BankPosProfit { get; set; }

        public bool PosIsActive { get; set; }

        public double PercentageShare { get; set; }


        public virtual AccountGroupModel AccountGroup { get; set; }

        public virtual IEnumerable<InvoiceHeaderModel> InvoiceHeaders { get; set; }
        public virtual IEnumerable<InvoiceDetailModel> InvoiceDetailForChequeBank { get; set; }
        public virtual IEnumerable<InvoiceDetailModel> InvoiceDetailForRemittanceTo { get; set; }
        public virtual IEnumerable<InvoiceDetailModel> InvoiceDetailForRemittanceFrom { get; set; }
}


public class AccountViewModel : BaseViewModel<int>
    {
        private string _name;
        private int? _accountGroupId;
        private double _cutie;
        private string _tell;
        private string _mobile;
        private string _fax;
        private double _goldCredit;
        private int _amountCredit;
        private int _refundPeriode;
        private string _birthdate;
        private string _dateOfMarriage;
        private string _closeFriend;
        private bool _calculateVAT;
        private string _nationalCode;
        private string _zipCode;
        private string _address;
        private string _openingDate;
        private InvoiceType _invoiceType;
        private bool _isActiveAccount;
        private string _description;
        private string _branchName;
        private string _bankAccountNumber;
        private BankAccountType _bankAccountType;
        private string _bankAccountOwner;
        private double _bankPosProfit;
        private bool _posIsActive;
        private double _percentageShare;
        private AccountGroupViewModel _accountGroup;
        private IEnumerable<InvoiceHeaderViewModel> _invoiceHeaders;
        private IEnumerable<InvoiceDetailViewModel> _invoiceDetailForChequeBank;
        private IEnumerable<InvoiceDetailViewModel> _invoiceDetailForRemittanceTo;
        private IEnumerable<InvoiceDetailViewModel> _invoiceDetailForRemittanceFrom;

        public string Name 
        {
            get { return _name; }
            set { SetPropertyIfChanged(value, ref _name); }
        }
        public int? AccountGroupId
        {
            get { return _accountGroupId; }
            set { SetPropertyIfChanged(value, ref _accountGroupId); }
        }
        public double Cutie
        {
            get { return _cutie; }
            set { SetPropertyIfChanged(value, ref _cutie); }
        }
        public string Tell
        {
            get { return _tell; }
            set { SetPropertyIfChanged(value, ref _tell); }
        }
        public string Mobile
        {
            get { return _mobile; }
            set { SetPropertyIfChanged(value, ref _mobile); }
        }
        public string Fax
        {
            get { return _fax; }
            set { SetPropertyIfChanged(value, ref _fax); }
        }
        public double GoldCredit
        {
            get { return _goldCredit; }
            set { SetPropertyIfChanged(value, ref _goldCredit); }
        }
        public int AmountCredit
        {
            get { return _amountCredit; }
            set { SetPropertyIfChanged(value, ref _amountCredit); }
        }
        public int RefundPeriode
        {
            get { return _refundPeriode; }
            set { SetPropertyIfChanged(value, ref _refundPeriode); }
        }
        public string Birthdate
        {
            get { return _birthdate; }
            set { SetPropertyIfChanged(value, ref _birthdate); }
        }
        public string DateOfMarriage
        {
            get { return _dateOfMarriage; }
            set { SetPropertyIfChanged(value, ref _dateOfMarriage); }
        }

        public bool CalculateVAT
        {
            get { return _calculateVAT; }
            set { SetPropertyIfChanged(value, ref _calculateVAT); }
        }

        public string CloseFriend
        {
            get { return _closeFriend; }
            set { SetPropertyIfChanged(value, ref _closeFriend); }
        }
        public string NationalCode
        {
            get { return _nationalCode; }
            set { SetPropertyIfChanged(value, ref _nationalCode); }
        }
        public string ZipCode
        {
            get { return _zipCode; }
            set { SetPropertyIfChanged(value, ref _zipCode); }
        }
        public string Address
        {
            get { return _address; }
            set { SetPropertyIfChanged(value, ref _address); }
        }
        public string OpeningDate
        {
            get { return _openingDate; }
            set { SetPropertyIfChanged(value, ref _openingDate); }
        }
        public InvoiceType InvoiceType
        {
            get { return _invoiceType; }
            set { SetPropertyIfChanged(value, ref _invoiceType); }
        }
        public bool IsActiveAccount
        {
            get { return _isActiveAccount; }
            set { SetPropertyIfChanged(value, ref _isActiveAccount); }
        }
        public string Description
        {
            get { return _description; }
            set { SetPropertyIfChanged(value, ref _description); }
        }
        public string BranchName
        {
            get { return _branchName; }
            set { SetPropertyIfChanged(value, ref _branchName); }
        }
        public string BankAccountNumber
        {
            get { return _bankAccountNumber; }
            set { SetPropertyIfChanged(value, ref _bankAccountNumber); }
        }
        public BankAccountType BankAccountType
        {
            get { return _bankAccountType; }
            set { SetPropertyIfChanged(value, ref _bankAccountType); }
        }
        public string BankAccountOwner
        {
            get { return _bankAccountOwner; }
            set { SetPropertyIfChanged(value, ref _bankAccountOwner); }
        }
        public double BankPosProfit
        {
            get { return _bankPosProfit; }
            set { SetPropertyIfChanged(value, ref _bankPosProfit); }
        }
        public bool PosIsActive
        {
            get { return _posIsActive; }
            set { SetPropertyIfChanged(value, ref _posIsActive); }
        }
        public double PercentageShare
        {
            get { return _percentageShare; }
            set { SetPropertyIfChanged(value, ref _percentageShare); }
        }

        public AccountGroupViewModel AccountGroup
        {
            get { return _accountGroup; }
            set { SetPropertyIfChanged(value, ref _accountGroup); }
        }

        public IEnumerable<InvoiceHeaderViewModel> InvoiceHeaders
        {
            get { return _invoiceHeaders; }
            set { SetPropertyIfChanged(value, ref _invoiceHeaders); }
        }

        public IEnumerable<InvoiceDetailViewModel> InvoiceDetailForChequeBank
        {
            get { return _invoiceDetailForChequeBank; }
            set { SetPropertyIfChanged(value, ref _invoiceDetailForChequeBank); }
        }
        public IEnumerable<InvoiceDetailViewModel> InvoiceDetailForRemittanceTo
        {
            get { return _invoiceDetailForRemittanceTo; }
            set { SetPropertyIfChanged(value, ref _invoiceDetailForRemittanceTo); }
        }
        public IEnumerable<InvoiceDetailViewModel> InvoiceDetailForRemittanceFrom
        {
            get { return _invoiceDetailForRemittanceFrom; }
            set { SetPropertyIfChanged(value, ref _invoiceDetailForRemittanceFrom); }
        }
    }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jbogardcommented, Aug 18, 2018

It’s still the wrong repository. This behavior was split out. Check out https://github.com/AutoMapper/AutoMapper.Extensions.ExpressionMapping

On Sat, Aug 18, 2018 at 3:07 AM majidsoltani notifications@github.com wrote:

this work currectly in automapper 6.2.1 but not work in version 7.0.1 !

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AutoMapper/AutoMapper/issues/2767#issuecomment-414040528, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGYMrk7g_REbv7F5_iwalsNsv6FAXEZks5uR8s8gaJpZM4WCdK7 .

1reaction
lbargaoanucommented, Aug 18, 2018

That’s a different repository now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Error mapping types" error on AutoMapper for ICollection ...
MEMBER_Model model = Mapper. Map<MEMBER_Model>(item); Error mapping types. Numbers at #region labels showing relation flow.
Read more >
Resolve Invalid mapping expression specified errors from ...
API Gateway returns an Invalid mapping expression specified error when the proxy path parameter {proxy+} doesn't have a defined a URL path parameter...
Read more >
MapExpression throws "Missing type map configuration or ...
When trying to map the above expression, automapper throws an unsupported mapping error: Missing type map configuration or unsupported mapping.
Read more >
Mule Errors
Selector Expressions for Mule Errors. Mule errors are complex data types with several fields, such as a description and type. When logging and...
Read more >
Mapping Expression with SysRevID is invalid - ERP 10
It says Mapping expression for (AnyTable).SysRevID field is invalid: REsult of expression cannot be assigned to variable of “System.String” type ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found