Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Using this setup, everything worked.</strong> </p> <p><em>1) LINQ to SQL Query, 2) DB Tables, 3) LINQ to SQL Data Model in VS.NET 2008</em></p> <p><strong>1 - LINQ to SQL Query</strong></p> <pre><code>DataClasses1DataContext db = new DataClasses1DataContext(); var results = from threes in db.tableThrees join twos in db.tableTwos on threes.fk_tableTwo equals twos.id join ones in db.tableOnes on twos.fk_tableOne equals ones.id select new { ones, twos, threes }; </code></pre> <p><strong>2 - Database Scripts</strong></p> <pre><code>--Table One CREATE TABLE tableOne( [id] [int] IDENTITY(1,1) NOT NULL, [value] [nvarchar](50) NULL, CONSTRAINT [PK_tableOne] PRIMARY KEY CLUSTERED ( [id] ASC ) WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]; --Table Two CREATE TABLE tableTwo( [id] [int] IDENTITY(1,1) NOT NULL, [value] [nvarchar](50) NULL, [fk_tableOne] [int] NOT NULL, CONSTRAINT [PK_tableTwo] PRIMARY KEY CLUSTERED ( [id] ASC ) WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]; ALTER TABLE tableTwo WITH CHECK ADD CONSTRAINT [FK_tableTwo_tableOne] FOREIGN KEY([fk_tableOne]) REFERENCES tableOne ([id]); ALTER TABLE tableTwo CHECK CONSTRAINT [FK_tableTwo_tableOne]; --Table Three CREATE TABLE tableThree( [id] [int] IDENTITY(1,1) NOT NULL, [value] [nvarchar](50) NULL, [fk_tableTwo] [int] NOT NULL, CONSTRAINT [PK_tableThree] PRIMARY KEY CLUSTERED ([id] ASC ) WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]; ALTER TABLE tableThree WITH CHECK ADD CONSTRAINT [FK_tableThree_tableTwo] FOREIGN KEY([fk_tableTwo]) REFERENCES tableTwo ([id]); ALTER TABLE tableThree CHECK CONSTRAINT [FK_tableThree_tableTwo]; </code></pre> <p><strong>3 - LINQ to SQL Data Model in Visual Studio</strong> </p> <p><a href="http://i478.photobucket.com/albums/rr148/KyleLanser/ThreeLevelHierarchy.png" rel="nofollow noreferrer">alt text http://i478.photobucket.com/albums/rr148/KyleLanser/ThreeLevelHierarchy.png</a> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload