I want to write an entity query for this SQL command:
SELECT * FROM provider WHERE serial
NOT IN ( SELECT providerRef as Serial FROM ProviderTeam WHERE TeamRef=134)
I searched the internet but no answer.
I want to write an entity query for this SQL command:
SELECT * FROM provider WHERE serial
NOT IN ( SELECT providerRef as Serial FROM ProviderTeam WHERE TeamRef=134)
I searched the internet but no answer.
You can rewrite your IN clause as EXISTS and use the following linq command:
var q = from p in dbContext.Providers
where !dbContext.ProviderTeams.Any(pt => pt.TeamRef == 134 && pt.providerRef == p.serial)
select p;
I hope this is what you need:
using (var dbObj = new [DB_NAME]Entities())
{
var list = dbObj.provider.SqlQuery("SELECT * from provider where serila NOT IN ( select providerRef as Serial from ProviderTeam where TeamRef=134)").ToList();
}