Search code examples
c#linqjoincastle-activerecord

LINQ left join using Castle Active Records?


How can I execute a left join using LINQ and Castle Active Records?

If tried the following:

from account in AccountRecord.Queryable
join s in SchoolRecord.Queryable on account equals s.Account into schools
where account.PaymentType == "S"
select new { Account = account, School = schools.ElementAt(0) };

but that threw me the following exception:

Unable to cast object of type 'Remotion.Data.Linq.Clauses.GroupJoinClause' to type 'Remotion.Data.Linq.Clauses.FromClauseBase'.

executing the following works (but its not what I want, because I need a left join):

from account in AccountRecord.Queryable
where account.PaymentType == "S"
from school in SchoolRecord.Queryable
where school.Account == account
select new { Account = account, School = school };

Solution

  • It seems this is not possible at the moment.

    If I or someone else find(s) a working solution I will update this answer.