in Education by
I have two tables. Orders OrderID | UserID | OrderTotal 1 | 1 | 100 2 | 2 | 110 3 | 1 | 120 Users UserId | ProprtyType | PropertyValue 1 | 1 | Kevin 1 | 2 | Nolan 1 | 1 | FirstName 1 | 2 | Surname Using the following Query var query = from orders in context.Orders join users in context.Users on orders.UserID equals user.UserID where userData.Type == 211 || userData.Type == 212 1 | 1 | 100 | Kevin 1 | 1 | 100 | Nolan 2 | 2 | 110 | FirstName 2 | 2 | 110 | Surname 3 | 1 | 120 | Kevin 3 | 1 | 120 | Nolan Is it possible in Entity frame work to combine the results so it returns the following 1 | 1 | 100 | Kevin | Nolan 2 | 2 | 110 | FirstName | Surname 3 | 1 | 120 | Kevin | Nolan Or 1 | 1 | 100 | Kevin Nolan 2 | 2 | 110 | FirstName Surname 3 | 1 | 120 | Kevin Nolan Thanks JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
That Users table is really badly designed, IMO. If you keep the table layout, please rename it UserProperties. Also, your example code doesn't match your table layout or the suggested results. That being said, you can do something like this: var firstnames = from user in context.Users where user.PropertyType == 1 select new { Id = user.UserID, Firstname = user.PropertyValue }; var lastnames = from user in context.Users where user.PropertyType == 2 select new { Id = user.UserID, Lastname = user.PropertyValue }; var users = from fn in firstnames join ln in lastnames on fn.Id equals ln.Id select new { Id = fn.Id, Firstname = fn.Firstname, Lastname = ln.Lastname }; var query = from order in context.Orders join user in users on order.UserID equals user.Id select new { /*what you need to select*/ }; One good thing about Entity Framework is that the actual SQL queries are deferred as long as possible. So just querying for firstnames and lastnames will not generate a database connection. That comes later. Unfortunately, your table design makes it really difficult to utilize those benefits of EF.

Related questions

0 votes
    I'm running into a problem where my List is null when I tried to retrieve data from my form. It ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I am a very novice C# person so please dont be too hard on me Im trying to make a post request ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    i m developing a little tool on my Pocket PC using WM6 SDK but i would like to implement a finger ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    I am using .net framework 4.0 and working on Web deployment Setup, I have referenced the SMO Assemblies ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have an incoming json object that represents the data pulled from a database structure. I would like to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 24, 2022 in Education by JackTerrance
0 votes
    Department and store model. They are a one to one relationship. when I do the (Include) only some ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I've searched stackoverflow for a proper solution on generating a many-to-many relationship, using EF Core, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 13, 2022 in Education by JackTerrance
0 votes
    I'm using EF code first. By convention, I have added a foreign key and a reference to the foreign ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I want to test my Entities that are built using Entity Framework. My concern is that using Entity Framework ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 10, 2022 in Education by JackTerrance
0 votes
    I try to create database from entity framework code first follow with this tutorial http://www.asp.net/mvc ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    What is Database First Approach in MVC using Entity Framework?...
asked Apr 5, 2021 in Education by JackTerrance
0 votes
    I am trying to concatenate two fields from a list to display in a dropdown. Below is the code i ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    How should I handle this exception for API data requester? The Dostuff1,2,3 is 3 different functions that ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    How should I handle this exception for API data requester? The Dostuff1,2,3 is 3 different functions that ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
...