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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:33:33+00:00 2026-06-03T18:33:33+00:00

I have the following model. Subscription Packages PackageWidgets Widgets ———— ——– ————– ——- ID

  • 0

I have the following model.

Subscription    Packages    PackageWidgets    Widgets
------------    --------    --------------    -------
ID              ID        < PackageID         ID
PackageID    >              WidgetID       >

I am using Entity Framework 4 and a Subscription has a relationship to Package. And Package has a relationship to a list of Widgets.

Using Linq, I am trying to get a listing of all Widgets and if they are included in the current subscription. Perhaps it’s due to my SQL background that I’m just not seeing the query in Linq. SQL would involve a SELECT from Widgets, with a LEFT JOIN through a subselect of Subscriptions, Packages and PackageWidgets based on the passed in SubscriptionID.

The output I would expect would be something like WidgetID,IsIncluded such that I would have all Widget IDs and a boolean indicating the inclusion status.

I cannot seem to even get something remotely close to working in order to show what I’ve done so far.

Can anyone provide me with some insights on how to accomplish my query?

Update:
Here is what I’ve come close with, but it still doesn’t work. Maybe it will help illustrate what I am trying to accomplish though:

from subscription in Subscriptions
where subscription.ID == 3
let subWidgets = subscription.Package.Widgets
from widget in Widgets
join subWidget in subWidgets on widget.ID equals subWidget.ID into joined
from list in joined.DefaultIfEmpty()
select new {
    ID = widget.ID
    ,Selected = subWidget.ID != null
}

Update #2
Thanks to the accepted answer, this is what I ended up going with – which does what I need:

from widget in Widgets
from subWidgets in
  from subscription in Subscriptions
  where subscription.ID == 3
  select subscription.Package.Widgets
orderby widget.ID
select new { 
    Name = widget.WidgetName,
  Available = subWidgets.Contains(widget)
}

Thanks for the assist!

  • 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-06-03T18:33:35+00:00Added an answer on June 3, 2026 at 6:33 pm

    One way to approach it is breaking it up, so something like:

    var widgetsInSubscription =
        from subscription in Subscriptions
        where subscription.ID == 3
        from widget in subscription.Package.Widgets
        select widget;
    
    var allWidgets =
        from widget in Widgets
        select new
        {
            widget.ID,
            Selected = widgetsInSubscription.Contains(widget),
        };
    

    Or doing it based on the ID’s instead of the objects, something like:

    var widgetIDsInSubscription =
        from subscription in Subscriptions
        where subscription.ID == 3
        from widget in subscription.Package.Widgets
        select widget.ID;
    
    var allWidgets =
        from widget in Widgets
        select new
        {
            widget.ID,
            Selected = widgetIDsInSubscription .Contains(widget.ID),
        };
    

    Keep in mind that you can always do the query yourself if you want – in EF4 you can just call ExecuteStoreQuery with your own SQL

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

Sidebar

Related Questions

I have the following model classes: @Entity @Table(name = title) public final class Title
I have the following model entity: public class ScheduledTask { public virtual int ScheduledTaskId
I have problem using Fluent Nhibernate, I have following model. When I try to
I have a following model: class Car(models.Model): make = models.CharField(max_length=40) mileage_limit = models.IntegerField() mileage
I have the following Model pattern: public abstract class PARENTCLASS {...} public class CHILD_A_CLASS
I have the following model structure: class Container(models.Model): pass class Generic(models.Model): name = models.CharacterField(unique=True)
I have the following model and instance: class Bashable(models.Model): name = models.CharField(max_length=100) >>> foo
I have the following model: class User: name = models.CharField( max_length = 200 )
I have the following model association: a student model and has_many scores. I need
I have the following model setup - a User is interested in projects in

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.