admin管理员组

文章数量:1405864

I'm trying to make a join table by preprocessing its columns using aggregating functions, but if I do something like

fromQuerayble
    .SelectMany(fromElement => joinQueryable.Where(joinElement => fromElement.Id == joinElement.FromId).Select(joinElement => new { fromElement, joinedId = joinElement.Id.MySomeDbFunction()}))
    .ToList() 

then I get a

SELECT request..(fromQueryable elements), my_some_db_function(joined_table_id) 
FROM from_table 
CROSS JOIN joined_table 
WHERE from_table.id = joined_table.from_table_id`

, that is, using the function, The one I want to use in the join subquery is placed at the top level, which is why the query crashes because no aggregating functions have been applied to the rest of the columns.

I expect that nhibernate return something like

SELECT ..(from columns), joined_table.id 
FROM from_table 
CROSS JOIN (select my_some_db_function(joined_table.id) id from joined_table) joined_table 
WHERE joined_table.from_table_id = from_table.id

Actually for some context, I need it for using lateral join with array_agg + unnest functions on columns inside the subquery

本文标签: cIs there any way to get a join of a subquery in NHibernate LINQStack Overflow