无法将运算符“&&”应用于 'bool' 和 'Fuel.LoanPayments.LoanPayment' 类型的操作数
Cannot apply operator '&&' to operands of type 'bool' and 'Fuel.LoanPayments.LoanPayment'
我尝试用前置条件编写映射器
这是代码
configuration.CreateMap<Loan, LoanDto>()
.ForMember(x=> x.NextPaymentAmount, opt =>
{
opt.PreCondition(
src => (src.DirectDebitCollection.Count > 0) &&
(src.LoanPayments
.FirstOrDefault(x =>
x.LoanPaymentStatusId == (int)LoanPaymentStatusEnum.Due)));
opt.MapFrom(src=> src.DirectDebitCollection);
});
但是在这一行 opt.PreCondition(src => (src.DirectDebitCollection.Count > 0) && (src.LoanPayments.FirstOrDefault(x=> x.LoanPaymentStatusId == (int)LoanPaymentStatusEnum.Due)));
我遇到了这个错误
Cannot apply operator '&&' to operands of type 'bool' and 'Fuel.LoanPayments.LoanPayment'
我需要如何重写它?
是因为
(src.LoanPayments
.FirstOrDefault(x => x.LoanPaymentStatusId == (int)LoanPaymentStatusEnum.Due))
returns 列表中的一项
如果你使用
(src.LoanPayments
.Any(x => x.LoanPaymentStatusId == (int)LoanPaymentStatusEnum.Due)))
它会 return 如果列表中存在一个项目则为真,如果列表中不存在则为假
我尝试用前置条件编写映射器
这是代码
configuration.CreateMap<Loan, LoanDto>()
.ForMember(x=> x.NextPaymentAmount, opt =>
{
opt.PreCondition(
src => (src.DirectDebitCollection.Count > 0) &&
(src.LoanPayments
.FirstOrDefault(x =>
x.LoanPaymentStatusId == (int)LoanPaymentStatusEnum.Due)));
opt.MapFrom(src=> src.DirectDebitCollection);
});
但是在这一行 opt.PreCondition(src => (src.DirectDebitCollection.Count > 0) && (src.LoanPayments.FirstOrDefault(x=> x.LoanPaymentStatusId == (int)LoanPaymentStatusEnum.Due)));
我遇到了这个错误
Cannot apply operator '&&' to operands of type 'bool' and 'Fuel.LoanPayments.LoanPayment'
我需要如何重写它?
是因为
(src.LoanPayments
.FirstOrDefault(x => x.LoanPaymentStatusId == (int)LoanPaymentStatusEnum.Due))
returns 列表中的一项
如果你使用
(src.LoanPayments
.Any(x => x.LoanPaymentStatusId == (int)LoanPaymentStatusEnum.Due)))
它会 return 如果列表中存在一个项目则为真,如果列表中不存在则为假