Question

I'd like to perform a couple of SELECT stored procedure calls in parallel. I setup my context as follows:

public virtual DbSet<Task<GetCaseCaseContextModel>> CaseGetCaseContextData { get; set; }

My repo class then does the following:

        public async Task<List<GetCaseNotesContextModel>> GetCaseNotes(string caseId)
    {
        var notes = _context.CaseGetCaseContextData.FromSql("x_Fortellis_CaseGetCaseNotes @p0", caseId, caseId).ToListAsync();

        return notes;
    }

But I get the following error:

Severity Code Description Project File Line Suppression State Error CS0029 Cannot implicitly convert type 'System.Threading.Tasks.Task>>' to 'System.Collections.Generic.List' CaseManagement.Infrastructure.Database C:\Dev\Bitbucket\webscv\Fortellis\CaseManagement\CaseManagement.Infrustructure.Database\Repo\Case\GetCase\GetCaseRepoHelper.cs 72 Active

When I change the context to:

public virtual Task<DbSet<GetCaseCaseContextModel>> CaseGetCaseContextData { get; set; }

I get the following error:

Severity Code Description Project File Line Suppression State Error CS1061 'Task>' does not contain a definition for 'FromSql' and no accessible extension method 'FromSql' accepting a first argument of type 'Task>' could be found (are you missing a using directive or an assembly reference?) CaseManagement.Infrastructure.Database C:\Dev\Bitbucket\webscv\Fortellis\CaseManagement\CaseManagement.Infrustructure.Database\Repo\Case\GetCase\GetCaseRepoHelper.cs 70 Active

I'm ultimately want to call them using:

            GetCaseCaseContextModel caseData = new GetCaseCaseContextModel();
        List<GetCaseNotesContextModel> notes = new List<GetCaseNotesContextModel>();

        Parallel.Invoke(
            async () => caseData = await GetCaseData(caseId, dealerGroupId),
            async () => notes = await GetCaseNotes(caseId)
        );

        return new GetCaseContextModel()
        {
            CaseData = caseData,
            Notes = notes
        };

Thanks Alex

1
2
3/20/2019 6:32:34 PM

Popular Answer

You have to rewrite:

   public async Task<List<GetCaseNotesContextModel>> GetCaseNotes(string caseId)
    {
        var notes = await _context.CaseGetCaseContextData.FromSql("x_Fortellis_CaseGetCaseNotes @p0", caseId, caseId).ToListAsync();
        return notes;
    }

Put await

2
5/21/2019 3:35:18 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow