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

  • SEARCH
  • Home
  • 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 8995311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:36:11+00:00 2026-06-15T23:36:11+00:00

Say I have a big model with 4 models in it: m1, m2, m3,

  • 0

Say I have a big model with 4 models in it: m1, m2, m3, m4
I use a big model because my view needs all of them but only one model can de declared. Hence I declare the big model in mu view

I want to perform a join query on the data returned by m1 and m2; but I also want to return the result of this join query to my view
How can I do this?
Can i declare a model whose values will be that of the join query? How do I do that?
Thanks

EDIT

Say I have this, (from Yasser’s example)

public class MyMainModel {
public Students Student { get; set; }
public Cars Cars { get; set; }
public Houses house {get; set;}
}

public class Students {
   public int StudentNo { get; set; }
   public string Name { get; set; }
   public int Age { get; set; }
}

public class Houses{
    public int StudentNo {get; set;}
    public string houseName {get; set;}
}

public class Cars {
public int CarNo { get; set; }
public string Name { get; set; }
public string Make { get; set; }
}

I want my main model, MyMainModel to have the car model and a model displaying student names and house names. A model like

public class ModelFromOtherModels{
   public int StudentNo {get; set;}
   public string HouseName {get; set;}
}

That means I have to perform a Join query on the Student and Houses model. Somthing like

from s in Student
JOIN h in Houses ON h.StudentNo = s.Student No
Select new{
   StudentName = s.name,
   HouseName = h.houseName
}

So that at the end, MyMainModel will be

public class MyMainModel {
   public ModelFromOtherModels newModel { get; set; }
   public Cars Cars { get; set; }
}

How can I do this?

  • 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-15T23:36:12+00:00Added an answer on June 15, 2026 at 11:36 pm

    It is a little difficult to understand what you ask here, but here goes my try…

    Consider your model to be as shown below, where M1 is the Students class and M2 is the Cars class.

    public class MyMainModel {
        public Students Student { get; set; }
        public Cars Cars { get; set; }
    }
    
    public class Students {
        public int StudentNo { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }
    }
    
    public class Cars {
        public int CarNo { get; set; }
        public string Name { get; set; }
        public string Make { get; set; }
    }
    

    Here MyMainModel is a class which now holds these two classes together. Now the rest depends on what you mean by join query ?

    You said

    I want to perform a join query on the data returned by m1 and m2;

    Yes you can perform joins using LINQ.

    Below are few links that I found, see if they help you

    • https://stackoverflow.com/a/9722744/1182982
    • http://forums.asp.net/t/1354584.aspx
    • Create a list from two object lists with linq
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say have a string... String myString = my*big*string*needs*parsing; All I want is to
Say I have a big file in one directory and an older version of
I have a very big no say 'x' (10^18) and a number 'z' say
Referring to this question, let's say we have the following scenario - A model
I am working with information from big models, which means I have a lot
I have a model that looks like this: class ProjectImage(models.Model): big_thumb = ThumbnailField(upload_to='profiles', size=(500,
I've got a Backbone.Collection full of models; let's say that model is Car .
Let's say I have a User model, with a facebook_uid field corresponding to the
Say I have a single span element defined as an inline-block. It's only contents
I inherited a big model and have been trying to reverse engineer some of

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.