N
Nightcrawler
I have the following tables that I have dragged into a .dbml file
(have only included the keys for simplicity).
CREATE TABLE [dbo].[Catalog](
[CatalogId] [int] NOT NULL)
CREATE TABLE [dbo].[CatalogFavorite](
[UserId] [uniqueidentifier] NOT NULL,
[CatalogId] [int] NOT NULL)
A user can add catalog items to their favorites. A user can also
browse other users favorites.
I am trying to write a LINQ to SQL query where I am seeing another
users favorites but I would also like to see if I have any of those
favorites in my own favorites.
The following query would return all favorites for a particular user.
SELECT *
FROM CatalogFavorite
WHERE UserId = uniqueidentifier of the user I am viewing'
How can I rewrite the query to see if any of that users favorites are
in my favorites (I have my uniqueidentifer available for this query).
I assume I need another column (maybe of type bit) where the query
would return a true if I have the item in my favorites as well or a
false if I don't.
Any help would be highly appreciated.
Thanks
(have only included the keys for simplicity).
CREATE TABLE [dbo].[Catalog](
[CatalogId] [int] NOT NULL)
CREATE TABLE [dbo].[CatalogFavorite](
[UserId] [uniqueidentifier] NOT NULL,
[CatalogId] [int] NOT NULL)
A user can add catalog items to their favorites. A user can also
browse other users favorites.
I am trying to write a LINQ to SQL query where I am seeing another
users favorites but I would also like to see if I have any of those
favorites in my own favorites.
The following query would return all favorites for a particular user.
SELECT *
FROM CatalogFavorite
WHERE UserId = uniqueidentifier of the user I am viewing'
How can I rewrite the query to see if any of that users favorites are
in my favorites (I have my uniqueidentifer available for this query).
I assume I need another column (maybe of type bit) where the query
would return a true if I have the item in my favorites as well or a
false if I don't.
Any help would be highly appreciated.
Thanks