How do I properly load my related object? If I my entity is like this
[Required]
[ForeignKey("FK_SectionTypeId")]
public long SectionTypeId { get; set; }
public SectionType SectionType { get; set; }
And my db table has the SectionTypeId, how do I load the section type using the generic repository in abp?
Specify in WithDetails:
```c#
var section = _repository.WithDetails(s => s.SectionType).First(s => s.Id == input.Id);
# By default
Define `DefaultWithDetailsFunc` in ***EntityFrameworkCoreModule.cs**:
```c#
context.Services.AddAbpDbContext<*DbContext>(options =>
{
options.Entity<Section>(opt =>
{
opt.DefaultWithDetailsFunc = q => q.Include(s => s.SectionType);
});
});
A. No need to specify in WithDetails:
```c#
var section = _repository.WithDetails().First(s => s.Id == input.Id);
B. `Get` includes details by default:
```c#
var section = _repository.Get(input.Id);
ABP Framework's Entity Framework Core Integration Best Practices — Repository Implementation.
Thanks! That was it.
Most helpful comment
On demand
Specify in
WithDetails:```c#
var section = _repository.WithDetails(s => s.SectionType).First(s => s.Id == input.Id);
A. No need to specify in
WithDetails:```c#
var section = _repository.WithDetails().First(s => s.Id == input.Id);
Custom repository
ABP Framework's Entity Framework Core Integration Best Practices — Repository Implementation.