这是我的Acquirer Model类,我在其中管理请求属性
const clik = () => {
props.click(input);
setInput({ titel: "", content: "" });
};
这是我的响应类AcquirerDTO.cs,在那里我可以获取所有响应
public class Acquirer{
public string MERCHANTNO {get;set;}
public float TRANSACTIONAMOUNT{get;set;}
public DateTime PROCESSDATE{get;set;}
public Acquirer(){}
public Acquirer(float TRANSACTIONAMOUNT,DateTime PROCESSDATE,string MERCHANTNO){
this.TRANSACTIONAMOUNT=TRANSACTIONAMOUNT;
this.PROCESSDATE=PROCESSDATE;
this.MERCHANTNO=MERCHANTNO;
}
我的AutoMapperClass
AutoMapper.cs
public class AcquirerDTO{
public string MERCHANTNO {get;set;}
public float TRANSACTIONAMOUNT{get;set;}
public DateTime PROCESSDATE{get;set;}
}
}
这是完成映射的地方,我收到此错误映射类型: <> f__AnonymousType2`2 []-> AcquirerDTO
public class AutoMapping : Profile
{
public AutoMapping()
{
CreateMap<Acquirer, AcquirerDTO>();
}
}
答案 0 :(得分:0)
我是这样完成的
var datasendd = datasend
.GroupBy(s => new { s.MerchantNo, s.ProcessDate })
.Select(g =>
new Acquirer
{
PROCESSDATE = g.Key.ProcessDate,
TransactionAmountSum = g.Sum(x => x.TransactionAmount)
}).ToArray();
List<AcquirerDTO> listDest = _mapper.Map<Acquirer[], List<AcquirerDTO>>(datasendd);