I am trying to implement the query below using LLBLGen:
SELECT COUNT(componentid) FROM
(
select ss.componentid
from
StructuredSystem ss
inner join StructuredSystemProducts ssp1 on ss.componentid = ssp1.systemid
and ssp1.componentid = 3395
inner join StructuredSystemProducts ssp2 on ss.componentid = ssp2.systemid
and ssp2.componentid = 3864
inner join StructuredSystemProducts sspCount on ss.componentid = sspCount.systemid
where ss.componentid <> 0
group by ss.componentid
having count(sspCount.componentid) = 2
) foo
I coded this by building up the inner query, then using DataAccessAdapter.GetDBCount().
The generated SQL looks fine, EXCEPT that the inner query (the SELECT against my base Entity table, "StructuredSystem") includes all fields, as if I were doing a FetchEntityCollection(). Since the GROUP BY only requires the one field (componentId), having all the other fields in the SELECT causes a SQL error.
I just need some way to exclude the unnecessary fields from the SELECT list, but I didn't see a way to use an ExcludeIncludeFieldsList. Any suggestions would be appreciated.
This is using SQL 2005, LLBLGen 2.5 (v2.0.50727), Adapter templates