我一直在寻找一种将类属性映射到表列的简单方法,我发现了Dapper流畅的映射,我认为这将是人们仅需编写即可映射的大量样板代码的理想选择。列的属性。但这似乎不起作用。
constructor(
private janelaAtualizacaoService: JanelaAtualizacaoService,
private segmentoInfoService: SegmentoInformacaoService,
private empresaService: EmpresaService,
private route: ActivatedRoute,
private router: Router, private fb: FormBuilder, private location: Location,
private changeDetector: ChangeDetectorRef, private localeService: LocaleService
) {
this.criarJanelas();
}
public get textoAvisos() {
return this.janelaAtualizacaoForm .get('textoAvisos') as FormArray;
}
criarJanelas() {
this.janelaAtualizacaoSelecionado = [];
this.janelaAtualizacaoForm = new FormGroup({
textoAvisos: new FormArray([
new FormGroup({
assTipo: new FormControl('', [Validators.required]),
msgTipo: new FormControl('', [Validators.required]),
dataTipo: new FormControl('', [Validators.required])
})
])
});
}
然后,当我尝试保存数据时,出现异常,表明表中不存在列FluentMapper.Initialize(c =>
{
c.AddMap(new MarginSummaryMap());
});
[Serializable]
[Table("PbCash")]
public class MarginSummary : Entity
{
public long RunId { get; set; }
public DateTime? BusinessDate { get; set; }
[Write(false)]
public DateTime ProcessDate { get; set; }
public string Broker { get; set; }
public string BrokerAccountId { get; set; }
public string Account { get; set; }
public string Folio { get; set; }
public decimal? ActualExcessOrDeficit { get; set; }
[Write(false)]
public decimal? ProjectedExcessOrDeficit { get; set; }
public string Comment { get; set; }
}
public class MarginSummaryMap : EntityMap<MarginSummary>
{
public MarginSummaryMap()
{
Map(c => c.ActualExcessOrDeficit).ToColumn("ExcessOrDeficit");
}
}
。嗯,事实并非如此,映射应该转换为实际的列ActualExcessOrDeficit
。
这似乎是ExcessOrDeficit
中的错误,因为如果我将类型从Dapper.FluentMap
更改为decimal?
,问题就会解决。
有人在工作吗-我很想知道如何解决这个问题。