我有一個命令
public class UpdateEntityCommand: IRequest<bool>
{
public int Id { get; set; }
public IEnumerable<OtherEntityDto> Instruments{ get; set; }
}
我需要在一個請求中更新許多物體。我可以做這樣的事情還是有更好的方法?
public class UpdateEntitiesCommand: IRequest<bool>
{
public IEnumerable<UpdateEntityCommand> Commands { get; set; }
}
uj5u.com熱心網友回復:
假設您的 OtherEntityDto 是這樣的:
class OtherEntityDto
{
public Guid Id {get;set;}
public string Name {get;set;}
}
我會怎么做是有一個命令,例如:
public class UpdateInstrumentsCommand: IRequest<bool>
{
public IEnumerable<OtherEntityDto> UpdatedInstrumemnts {get;set}
}
然后,在命令處理程式中,我會將持久化的物體與UpdatedInstrumemnts基于Id屬性的內容進行匹配,并相應地更新它們的名稱。我希望這對你有意義
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/470998.html
