public async IAsyncEnumerable <SubItemDTO> GetByIdAsync(Guid id) { Data.Entities.SubItem subItem = await _subItemContext.FindAsync <Data.Entities.SubItem>(id); if (subItem is null || subItem.DeletedDate != null) { yield return(new SubItemDTO()); } IAsyncEnumerable <SubItemPropertyDTO> subItemPropertyDTOList = _subItemPropertyService.GetBySubItemAsync(subItem.Id); await foreach (var item in CloneSubItemEntity(subItem, subItemPropertyDTOList)) { yield return(item); } }
public async IAsyncEnumerable <SubItemDTO> CloneSubItemEntity(Data.Entities.SubItem subItem, IAsyncEnumerable <SubItemPropertyDTO> subItemPropertyDTOList) { List <SubItemPropertyDTO> subItemPropertyList = new List <SubItemPropertyDTO>(); await foreach (var subItemProperty in subItemPropertyDTOList) { subItemPropertyList.Add(subItemProperty); } ; SubItemDTO subItemDTO = new SubItemDTO { Id = subItem.Id, SubItemPropertyList = subItemPropertyList, CreatedDate = subItem.CreatedDate, CreatedBy = subItem.CreatedBy, UpdatedDate = subItem.UpdatedDate, UpdatedBy = subItem.UpdatedBy, DeletedDate = subItem.DeletedDate, DeletedBy = subItem.DeletedBy, }; yield return(subItemDTO); }