Complex SQL Query to NHibernate DetachedCriteria or HQL -


I need to return the following SQL query result:

  select Person.FirstName , Person.LastName, OrganisationUnit.Name UnitName, SkillsArea as RS_SkillsArea.Name, Activity.Name ActivityName, Activity.CLASS, Activity.StartsOn, Activity.EndsOn, SUM (ActivityCost.CostAmount) / NULLIF ((Select COUNT ( Join in INNER Effort by registering as well as Registration ID. In the registration register, best wishes on the results. Current ResultID = Attempt Resolutions. Registrations ID = Exchange ResultSmurey Registration ID where (Registration Status = 1) and (Registration. ActivityDID = ActivityActiveIDID) and (Unbreakable Resolute Seari.Attendance Status <1) , 0) Register registration with registration number INNER as registration from AS Personal Cost Registration. Aktivitiaidi = Gtividhi.aktiviaid inner join in Rijaratat ion_1.PersonId = Person.PersonId interiors include Person.OrganisationUnitId = OrganisationUnit.OrganisationUnitId interiors are Registration_1.CurrentResultId = on AttemptResultsSummary AttemptResultsSummary.AttemptResultsSummaryId and Registration_1.RegistrationId = AttemptResultsSummary.RegistrationId and Activity. ActivityId = AttemptResultsSummary.ActivityId and Person.PersonId = OrganisationUnit Join AttemptResultsSummary.PersonId Interactive on Activity.ActivityId = ActivityCost.ActivityId Left External ActivityCost JOIN (Selection Category.Name, Category.CategoryId Division, based on the inner category, CategoryGroup. [S Mouth] = Where to join CategoryGroup.Name = N'Skills Area ')) Join RS_SchoolStyleInner Join ActivityInCategory at RS_SkillsArea.CategoryId = ActivityInCategory.CategoryId on Activity.ActivityId = ActivityInCategory.ActivityId and AttemptResultsSummary.AttendanceStatus & lt; & Gt; 1 group by R.C.Cilaria.name, person.first name, person.name, activity. Name, activity. Class, activity.start on, activity Presentations, Activity Activation End, Organized. Name, effort & Lt; & Gt; 1  

Essentially there is no way to do the same against SQL rather than institutions either by using either DetachedCriteria or HQL

Two Challenges

  1. Query for value calculation per line

  2. joining the derived table (which is an external value of this value Do not need to be included)

D appreciate any signs of changes in infrastructure I do not want to use SQL due to problems with problems (refactoring support)

"post-text" itemprop = "text">

Take a look at official HQL example @

In my opinion, 'get derivative', HQL.

will be even easier to pull off in terms of performance, to start my first time how much it can spend using your favorite profiler using your SQL, and then How much does NHProf use on NHibernate?


Comments