HQL query in C#

Asked

Viewed 73 times

3

Guys, I’m having trouble with HQL and C#. I have the following method:

public IList<int> GetListYear(Guid educationalInstitutionId, Guid academicLevelId, Guid? locationId, Guid? programOfferedId)
{
    //Implementar o HQL
}

And I have the following query:

"select distinct ConclusionYear
from AlumniProgramOffered
inner join AlumniSignup
inner join ProgramOffered*
inner join Program
where AlumniSignup.EducationalInstitution.Identity = educationalInstitutionId
and Program.AcademicLevel.Identity = academicLevelId
and ProgramOffered.Location.Identity = locationId or locationId is null
and ProgramOffered.Identity = programOfferedId or programOfferedId is null"

I need, through HQL, to perform this query by passing the parameters I receive in my method Getlistyear

1 answer

0

To be sure how this query would look, I would need the code of all its entities. But, probably, your HQL consultation would look like this:

select distinct ConclusionYear as cy
from AlumniProgramOffered as apo
 join apo.AlumniSignup as as
 join as.ProgramOffered as po
 join po.Location as loc
 join po.Program as pr
 join pr.AcademicLevel as al
 join pr.EducationalInstitution as edu
where edu.Identity = :educationalInstitutionId
 and al.Identity = :academicLevelId
 and loc.Identity = :locationId or locationId is null
 and po.Identity = :programOfferedId or programOfferedId is null

This, of course, is just the HQL query. The rest of the code for this HQL call I’m assuming you already know how to do.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.