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 6667569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:56:50+00:00 2026-05-26T02:56:50+00:00

My database structure is this: an OptiUser belongs to multiple UserGroup s through the

  • 0

My database structure is this: an OptiUser belongs to multiple UserGroups through the IdentityMap table, which is a matching table (many to many) with some additional properties attached to it. Each UserGroup has multiple OptiDashboards.

I have a GUID string which identifies a particular user (wlid in this code). I want to get an IEnumerable of all of the OptiDashboards for the user identified by wlid.

Which of these two Linq-to-Entities queries is the most efficient? Do they run the same way on the back-end?

Also, can I shorten option 2’s Include statements to just .Include("IdentityMaps.UserGroup.OptiDashboards")?

using (OptiEntities db = new OptiEntities())
{
    // option 1
    IEnumerable<OptiDashboard> dashboards = db.OptiDashboards
        .Where(d => d.UserGroups
            .Any(u => u.IdentityMaps
                .Any(i => i.OptiUser.WinLiveIDToken == wlid)));

    // option 2
    OptiUser user = db.OptiUsers
        .Include("IdentityMaps")
        .Include("IdentityMaps.UserGroup")
        .Include("IdentityMaps.UserGroup.OptiDashboards")
        .Where(r => r.WinLiveIDToken == wlid).FirstOrDefault();

    // then I would get the dashboards through user.IdentityMaps.UserGroup.OptiDashboards
    // (through foreach loops...)
}
  • 1 1 Answer
  • 0 Views
  • 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-26T02:56:51+00:00Added an answer on May 26, 2026 at 2:56 am

    You may be misunderstanding what the Include function actually does. Option 1 is purely a query syntax which has no effect on what is returned by the entity framework. Option 2, with the Include function instructs the entity framework to Eagerly Fetch the related rows from the database when returns the results of the query.

    So option 1 will result in some joins, but the “select” part of the query will be restricted to the OptiDashboards table.

    Option 2 will result in joins as well, but in this case it will be returning the results from all the included tables, which obviously is going to introduce more of a performance hit. But at the same time, the results will include all the related entities you need, avoiding the [possible] need for more round-trips to the database.

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

Sidebar

Related Questions

I have created a table on an Oracle 10g database with this structure :
I have a database structure that has a Person table which contains fields such
this is a part from my database structure: Table: Item Columns: ItemID, Title, Content,
I have a table setup in my database with this structure: I have running
how to make a good MySQL Database Table Structure from this XML-Code? <xml> <product>
I have a simple database structure like this: entries table +----+-----------+------------+-----------+------+ | id |
My DataBase Table Structure is like this : ID(Primary Key ) , Title (Nvarchar)
I have a MySQL database with a structure like this... Site has many Sensors
My database structure is like this: Members table |id|username|... Messages table |id|fromId|toId|content In the
This is my database structure I have four tables. Table LocalArea and Lanungaue have

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.