Question

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

Était-ce utile?

La solution

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);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top