'Loading related data using repository pattern and uow with EF Core 6
I have three entities
public partial class UnitsOfMeasure
{
public UnitsOfMeasure()
{
ItemNavision = new HashSet<ItemNavision>();
}
public int Id { get; set; }
public string Description { get; set; }
public string Code { get; set; }
public virtual ICollection<ItemNavision> ItemNavision { get; set; }
}
public partial class ItemNavision
{
public ItemNavision()
{
ExpressionOfNeeds = new HashSet<ExpressionOfNeeds>();
}
public int Id { get; set; }
public string Description { get; set; }
public string Code { get; set; }
public int FkunitsOfMeasure { get; set; }
public virtual UnitsOfMeasure FkunitsOfMeasureNavigation { get; set; }
public virtual ICollection<ExpressionOfNeeds> ExpressionOfNeeds { get; set; }
}
public partial class ExpressionOfNeeds
{
public int Id { get; set; }
public int IdItemNavision { get; set; }
public double Quantity { get; set; }
public virtual ItemNavision IdItemNavisionNavigation { get; set; }
}
I have use this method to return related data
public async Task<IEnumerable<T>> GetAllIncluding(params Expression<Func<T, object>>[] includeProperties)
{
IQueryable<T> query = dbSet;
foreach (Expression<Func<T, object>> includeProperty in includeProperties)
{
query = query.Include<T, object>(includeProperty);
}
return await query.ToListAsync();
}
and I implemented in this way
GCData.DataSource = await _unitOfWork.ExpressionOfNeedss.GetAllIncluding(x => x.IdItemNavisionNavigation);
but when I run the program I get this value instead of actual value
Domain.Entities.ItemNavision
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

