Child Entity not update from main Repository
- ABP 4.4**.
- UI Angular
- EF Core
- no Exception. but await Repository.UpdateAsync(queryResult); not update the child entity
I am unable to update the child entity with the main repository. All Entities inherit from AuditedEntity.
this line only update the File " await Repository.UpdateAsync(queryResult);" not updating the family list
public partial class File : AuditedEntity<Guid>//Main Enity
{
private File()
{
Families = new HashSet<Family>();
}
public string FileNumber { get; set; }
public virtual ICollection<Family> Families { get; set; }
}
public partial class Family : AuditedEntity<Guid>//Child Entity
{
public string Prefix { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public int? Relationship { get; set; }
public Guid FileId { get; set; }
public virtual File File { get; set; }
}
public class FileAppService : CrudAppService<
File, //The Book entity
FileDto, //Used to show books
Guid, //Primary key of the book entity
PagedAndSortedResultRequestDto, //Used for paging/sorting
CreateUpdateFileDto>, //Used to create/update a book
IFileService
{
IRepository<Family, Guid> _Familyrepository;///Child Repository
public FileAppService(IRepository<File, Guid> repository, IRepository<Family, Guid> familyrepository){
_Familyrepository = familyrepository;
}
public async Task<ResponseDto> UpdateFamilyInfo(List<FamilyInfoDto> requestFamilyInfo)
{
var queryable = await Repository.GetQueryableAsync();
var file = from f in queryable
join fa in _Familyrepository
on f.Id equals fa.FileId
where f.Id == requestFamilyInfo.FirstOrDefault().FileId
select f;
var queryResult = await AsyncExecuter.FirstOrDefaultAsync(file);
queryResult.Families = ObjectMapper.Map<ICollection<FamilyInfoDto>, ICollection<Family>>(requestFamilyInfo, queryResult.Families);
await Repository.UpdateAsync(queryResult);
return null;
}
}
This is has nothing to do with ABP. check https://docs.microsoft.com/en-us/ef/core/saving/related-data
but my problem is not solved. child entity loading is a problem which is not working. Insertion is working fine. with below code but loading of file with childs does not work for me(includeDetails).
var File= new File { FileNumber = "123", familylies = new List
var queryable = await Repository.GetAsync( x => x.Id == requestBasicInfo.Id,true);
Please help.
Thanks Sir,
but my problem is not solved. child entity loading is a problem which is not working. Insertion is working fine. with below code but loading of file with childs does not work for me(includeDetails).
var File= new File { FileNumber = "123", familylies = new List
var queryable = await Repository.GetAsync( x => x.Id == requestBasicInfo.Id,true);
Please help.
On Mon, Aug 16, 2021 at 7:28 PM liangshiwei @.***> wrote:
This is has nothing to do with ABP. check https://docs.microsoft.com/en-us/ef/core/saving/related-data
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/abpframework/abp/issues/9831#issuecomment-899557038, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVADWQMWAO53HLH5IJDDNZDT5EOATANCNFSM5CHZUS2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
See https://docs.abp.io/en/abp/latest/Entity-Framework-Core#defaultwithdetailsfunc
Thanks, This solved my problem . Really Thanks for your effort,😀 I am happy.
On Mon, Aug 16, 2021 at 8:26 PM liangshiwei @.***> wrote:
See https://docs.abp.io/en/abp/latest/Entity-Framework-Core#defaultwithdetailsfunc
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/abpframework/abp/issues/9831#issuecomment-899601027, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVADWQKUCVXAS523V7CUWVLT5EUZHANCNFSM5CHZUS2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .