Frage

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

War es hilfreich?

Lösung

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);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top