Error Mappin Expression type
See original GitHub issueSource/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:
- Created 5 years ago
- Comments:5 (2 by maintainers)
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:
That’s a different repository now.