示例#1
0
        public async IAsyncEnumerable <SubItemDTO> GetAllAsync()
        {
            /*var subItemWithProp = await _context.SubItem.Join(
             *                                  _context.SubItemProperty,
             *                                  subItem => subItem.Id,
             *                                  subItemProperty => subItemProperty.SubItem.Id,
             *                                  (subItem, subItemProperty) => new
             *                                  {
             *                                      SubItemId = subItemProperty.SubItemId,
             *                                      SubItemPropId = subItemProperty.Id,
             *                                      SubItemDeletedDate = subItem.DeletedDate,
             *                                      SubItemPropDeletedDate = subItemProperty.DeletedDate
             *                                  }
             *                                  ).Where(x => x.SubItemDeletedDate == null &&
             *                                               x.SubItemPropDeletedDate == null).ToListAsync();
             */
            List <Data.Entities.SubItem> subItemList = await _subItemContext.SubItem.ToListAsync();


            foreach (var subItem in subItemList)
            {
                if (subItem.DeletedDate is null)
                {
                    IAsyncEnumerable <SubItemPropertyDTO> subItemPropertyDTOList = _subItemPropertyService.GetBySubItemAsync(subItem.Id);

                    IAsyncEnumerable <SubItemDTO> subItemDTO = CloneSubItemEntity(subItem, subItemPropertyDTOList);

                    await foreach (var item in subItemDTO)
                    {
                        yield return(item);
                    }
                }
            }
        }
        public ActionResult <IAsyncEnumerable <SubItemPropertyDTO> > GetBySubItem(Guid subItemId)
        {
            IAsyncEnumerable <SubItemPropertyDTO> list = _subItemPropertyService.GetBySubItemAsync(subItemId);

            return(Ok(list));
        }