开发者

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 };


It seems this is not possible at the moment.

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


Using the DefaultIfEmpty() may do it.

http://social.msdn.microsoft.com/forums/en-US/linqprojectgeneral/thread/d9a19de2-87c7-48ff-9c93-5fbcd0db3983/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜