Question: I have run into the problem of sending data, a simple int type, from a dialogue fragment to all the fragments within a viewpager. I have an activity that hosts both the dialogue fragment and the viewpager. I know how to send data from the dialogue fragment to the activity using an interface defined in the dialogue fragment and implementing it within the activity itself. I was thinking maybe it had something to do with the onAttach method but i am not sure. i feel i am overlooking a simple solution here. please help! thanks!

Answer: 
Your call to `ToListAsync()` is returning a `Task`, which may not have completed executing by the time you return from the method. The best solution would be to make the method async, like so:

```
public async Task<IActionResult> GetApplications()
{
   var result = await context.Applications.Include(a=> a.AplicantCompany)
      .Include(c=>c.CreditorCompany)
      .ToListAsync();
   return Ok(result);
}

```

These changes will cause the method to wait for all the results before continuing to the `return` statement, while allowing other requests to run while this one is waiting for its data.

The second case probably won't work, as EF wants to load the entire entity with `Include`. If you want to load another entity that's referenced by `AplicantCompany`, you can use 

```
.Include(a => a.AplicantCompany).ThenInclude(c => c.Entity)

```

Actually, according to [this answer](https://stackoverflow.com/a/46477084/1210520), you might be able to do (I haven't tried it):

```
var result = await context.Applications.Select(a => new {
    Application = a,
    CreditorCompany = a.CreditorCompany.Name,
    ApplicantCompany = a.AplicantCompany.Name}).ToListAsync();

```
First of,

The `Include()` method is used to load related data, not properties on related data. 
Which means, to load the name property of the related AplicantCompany and CreditorCompany on the entity Applications, your first query is correct.
It will include the name properties of both related entities

```
var result = context.Applications.Include(a=> a.AplicantCompany)
                .Include(c=>c.CreditorCompany)
                .ToList();

```

Then secondly, if you're using the async method ToListAsync() you need to await the task

```
[HttpGet("/api/applications")]
public async Task<IActionResult> GetApplications()
{
    var result = await context.Applications.Include(a=> a.AplicantCompany)
                .Include(c=>c.CreditorCompany)
                .ToListAsync();
    return Ok(result);
}

```