Solved

Linq query help - table that references itself

Posted on 2014-10-06
1
181 Views
Last Modified: 2016-02-15
Hello,

I need to figure how the write the following using linq to entities.  I have a table that references itself, and the syntax is over my head!

Here is the SQL of exactly what I need to run
select pc.*
from projects p
	join projectReferences pr on p.projectGuid=pr.projectGuid
	join projectContent pc on pr.referenceProjectID=pc.projectID
where p.projectID = 1234

Open in new window


The table projectReferences here is what is confusing me, it's not part of my EF model, since there is simply a navigation property.

Any Ideas?
0
Comment
Question by:raterus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 33

Accepted Solution

by:
raterus earned 0 total points
ID: 40365906
Figured this one out using the following linq.  This is using a navigate propoperty "IsReferencedBy" that I created.

(from p in DB.projects
         from pc in DB.projectContents
         where pc.project.isReferencedBy.Any(r => r.projectID == p.projectID
                        && p.projectID == 1234)

Open in new window

0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question