0

I am using Entity Framework with ASP.NET 4.0. This is a simple problem where i have to hide a Install button for all gadgets already installed by my user. I am using repeater for the databinding and UI generation.

Database schema is as below

  Apps
----------
AppId
Appname
Description

Applications installed for a user will be added to below table

InstalledApps
------------
Rid
UserId
AppId

so entity ends up like this

Users
Apps
InstalledApps

I would want entity framework equivalent of below SQL

SELECT AppId,AppName,Description FROM Apps WHERE Apps.AppId NOT IN (SELECT AppId FROM InstalledApps WHERE UserId = 1)

note: If there is more simple query that would yield same result i would love to know. This just popped out of my head

Deeptechtons
  • 10,945
  • 27
  • 96
  • 178

1 Answers1

0

I assume that your tables are connected with each other and you should query from InstalledApps

 var f = from c in dbContext.InstalledApps
    where c.UserId != 1
    select new
    {
    c.AppId,
    c.App.AppName,
    c.App.Description
    };

This will not generate same SQL, but will bring result that you asking.

Florim Maxhuni
  • 1,421
  • 1
  • 17
  • 35