Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 419367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:46:13+00:00 2026-05-12T18:46:13+00:00

Can anyone help? I have the following structure using associations, and as you can

  • 0

Can anyone help?

I have the following structure using associations, and as you can see v.StructureType.Description works great as its a 1 to 1 association, but i need to get in my example below v.StructureGroup.StructureGroupTariffs.Tariff.Price but StructureGroupTariffs is a Pivot table to interlink the StructureGroup and Tariffs, hence its a Many to Many so it returns a EntitySet, I understand the issue now but i am unsure how to fix it

    from v in Houses
       select new 
       {
          Id = v.Id,
          Color = v.Color.Description,
          StructureType= v.StructureType.Description,
          Price = v.StructureGroup.StructureGroupTariffs. // Tariff.Price doesn't appear because its MANY to ONE
       }

So understanding that my structureGroupTariffs is my pivot (inter linking table) i must pass in

                 IdTariff  and  StructureGroupId

this then gives me a 1 to 1… So i presume i can then use StructureGroupTariffs.Tariff.Price ??? as this will then return a 1 to 1 between StructureGroup and Tariff

I am a little confused and would really appreciate some help.

I understand the issue now but unsure of how i can fix it.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:46:14+00:00Added an answer on May 12, 2026 at 6:46 pm

    Think about how you would solve this kind of query in SQL and I think you can apply that reasoning. There are two primary ways of writing this kind of join: the first is to use inner joins from the main table to the join table and again to the result table, with appropriate filters in place. If you are not careful to filter the join correctly you would get multiple rows per main table (which is effectively why you are getting an EntitySet. If you use .FirstOrDefault() against that entity set you will get the Entity you are looking for (assuming that you have filtered down to a single result: if not you will get some random result).

    An alternative would be to write a subquery, such as

    Price = (from t in v.StructureGroup.StructureGroupTariffs.Tariffs 
    where t.StructionGroupID = v.StructureGroupID 
    and t.IdTariff = *not sure where this filter comes from*
    select t.Price).First()
    

    The missing filter above is likewise a problem for the first approach: either way you need to uniquely identify the t.Price you want.

    Here is an example of inner joins (simplified from a schema of mine where Docs are many to many with DocTags via the Doc_DocTag table.

    from d in Docs 
    join ddt in Doc_DocTags on d.DocGuid equals ddt.DocGuid
    join dt in DocTags on ddt.DocTagID equals dt.DocTagID
    select new {
        d.DocName, dt.DocTagName
    }
    

    If I wanted only one tag:

    from d in Docs 
    join ddt in Doc_DocTags on d.DocGuid equals ddt.DocGuid
    join dt in DocTags on ddt.DocTagID equals dt.DocTagID
    where dt.DocTagName == "Target"
    select new {
        d.DocName, dt.DocTagName
    }
    

    This would find only docs with a tag of Target (which would further ensure that multiple DocTags are not possible).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone help? I have been using the entity framework and its going well
Learning xml, Can anyone help me? I have following XML code: **<book lang=en>name of
Can anyone please help. I'm following a tutorial found here as I have a
can anyone help. I have recently moved servers, its IIS7 rather that our previous
Can anyone help me with a quick regex problem? I have the following HTML:
I have the following text as an example: \n\t\t\t\t\t3 comments Can anyone help me
Can anyone help me. I have a table containing a nested table in one
can anyone help? I have reading various blogs and it appears to include i18n
can anyone help? I have a simple html file which i am filling via
Can anyone help? I have an issue with calling a asp.net webservice from jquery..

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.