Solved

Linq query help - table that references itself

Posted on 2014-10-06
1
179 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help converting bitmap to image in VB.Net 8 45
linq .concat equivalent with expression syntax 4 23
parse string in c# 5 29
C# LINQ 5 25
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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