is it possible to write such a query via linq in BlToolkit?

SELECT  * FROM X pd
WHERE EXISTS (SELECT 1 FROM Y mm
WHERE VersionMaster > 0 
)

I mean - is it possible to write an 'Exists' construct in linq so the BlToolkit would understand it?

thanks

有帮助吗?

解决方案

Method Any() is the equivalent of exists in the sql. It is used as following.

var query = (from pd in db.TableX
    where (from mm in db.TableY where mm.VersionNUmber > 0).Any()
    select pd);

or

var query = (from pd in db.TableX
    where db.TableY.Any( mm => mm.VersionNUmber > 0 )
    select pd);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top