Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6101165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:28:08+00:00 2026-05-23T13:28:08+00:00

How can I execute the following query using Castle ActiveRecords and LINQ or HQL?

  • 0

How can I execute the following query using Castle ActiveRecords and LINQ or HQL?

SELECT a.id, s.classes, COUNT(p.id), MAX(p.date) AS last, MIN(p.date) AS first
FROM account a
LEFT JOIN school s ON s.account_id = a.id
LEFT JOIN user u ON u.account_id = a.id
LEFT JOIN points p ON p.user_id = u.id
WHERE payment = “S”
GROUP BY a.id

The tables are related in the following way:
ER-Diagramm

I also have ActiveRecord classes for all tables with the correct relations defined (if I do the query in steps it works, but it is slow as there are a lot of rows) and I tried the following which didn’t worked:

var result = from account in AccountRecord.Queryable
             join s in SchoolRecord.Queryable on account equals s.Account into schools
             from school in schools.DefaultIfEmpty(null)
             join user in UserRecord.Queryable on account equals user.Account
             join p in PointsRecord.Queryable on user equals p.User into points
             where account.PaymentType == "S"
             select new { Account = account, School = school, Count = points.Count() };

which threw the following The method or operation is not implemented-Exception at:

NHibernate.Linq.Visitors.QueryModelVisitor.VisitGroupJoinClause(GroupJoinClause groupJoinClause, QueryModel queryModel, Int32 index)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:28:09+00:00Added an answer on May 23, 2026 at 1:28 pm

    Found the solution using HQL – I’m still open for a LINQ solution:

    HqlBasedQuery query = new HqlBasedQuery(typeof(AccountRecord),
        "SELECT a, s, COUNT(p), MIN(p.DateUTC), MAX(p.DateUTC) " +
        "FROM AccountRecord a " +
        "LEFT JOIN a.Schools s " +
        "LEFT JOIN a.Users u " +
        "LEFT JOIN u.Points p " +
        "WHERE a.PaymentType=:payment GROUP BY a.Id");
    query.SetParameter("payment", "S");
    var result = from object[] row in (ArrayList)ActiveRecordMediator.ExecuteQuery(query)
                    select new
                    {
                        Account = row[0] as AccountRecord,
                        School = row[1] as SchoolRecord,
                        Count = row[2],
                        First = (new DateTime(1970, 1, 1, 0, 0, 0, 0)).AddSeconds(Convert.ToDouble(row[3])),
                        Last = (new DateTime(1970, 1, 1, 0, 0, 0, 0)).AddSeconds(Convert.ToDouble(row[4]))
                    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with the following Linq query using Entity Framework: from o
I'm using Sybase::CTlib to query a Sybase server. However when I execute the following:
using the following LINQ query: EntityQuery<Questions> query = context.GetQuestionsQuery() .Where(o => o.SurveyQuestions.Any(o2 => o2.SurveyID
I can compile but can't execute the following code with the error (using Postgres):
In Perl, you can execute system commands using system() or `` (backticks). You can
How can I execute a.exe using the Cygwin shell? I created a C file
When I execute the following query on a database containing a table comm_list and
The following query returns data right away: SELECT time, value from data order by
I have the following prepared query I am using with mysql and php. It
I wish to execute the following query on my application's SQliteDatabase. String sql =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.