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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:52:41+00:00 2026-05-26T16:52:41+00:00

I have 2 tables within my EF4 project. They dont have a join. CustomerTable

  • 0

I have 2 tables within my EF4 project. They dont have a join.

CustomerTable
CustomerId
ConsumerName
AllowEmails

PurchaseTable
PurchaseId
CustomerId
PurchaseDate
……

What I am trying to do is return a grouped Customer when they have transactions within the PurchaseTable. If they haven’t made any purchases or consumer Id isn’t yet added to the CustomerId I want to ignore them.

I have a linq query that is working like I want

 var query = from t in ctx.PurchaseTable
                    join j in ctx.CustomerTable on t.CustomerId equals
                        j.ConsumerId
                        where j.AllowEmails==true
                    group t by new
                                   {
                                       t.CustomerId,
                                       j.ConsumerName,
                                       j.EmailAddress
                                   }
                    into g
                    select new {Customer = g.Key};

Now I could just do a foreach loop and add the results into a list however I think it would be nice to add to the list as part of the query.

This is what I have got so far.

  var data = (from t in ctx.PurchaseTable
                     join j in ctx.CustomerTable on t.CustomerId equals
                        j.CustomerId 
                    where j.AllowEmails== true
                    //group t by new //group t by new ConsumerModel
                    group t by new CustomerModel
                                   {
                                       CustomerName= t.CustomerName,
                                       Email= j.EmailAddress,
                                       CustomerId = j.CustomerId


                                   }
                    into g select g);

Can anyone point me in the right direction to fix my query?

Thanks for your help!

  • 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-26T16:52:42+00:00Added an answer on May 26, 2026 at 4:52 pm

    You need to select g.Key.

    g is an IGrouping<CustomerModel, Purchase> that includes the elements in the group.

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

Sidebar

Related Questions

I have two tables called clients, they are exactly the same but within two
I have a SQLite database, and several tables within that datbase. I am developing
I have a several tables nested within a table that I am parsing using
I'm trying to insert information into multiple tables within a database, i have managed
So in my EF4 project I have opened up the partial classes of both
Our client's database admins have requested that we don't use temp tables within our
I have a msql DB within with i have my tables.The tables has proper
I have 2 tables, each of which is contained within different divs, similar to
I have 2 tables, Pages and LinkPages. Within Pages i have the fields: pageID
I have 3 tables within my data base: User Table Documents Table User-ReadDoc Table

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.