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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:40:57+00:00 2026-05-24T01:40:57+00:00

I started with EF yesterday and I am in trouble to transform this simple

  • 0

I started with EF yesterday and I am in trouble to transform this simple query into EF sintax

Translate:

select a.city from offer o, address a, offer_address oa
where o.identifier = oa.offeridentifier 
and a.identifier = oa.addressidentifier
group by a.city
order by count(*) desc

Into:

var cities = (from o in db.offer
              from a in db.address
              from oa in db.offer_address
              where (o.identifier == oa.offeridentifier
                  && a.identifier == oa.addressidentifier)
              group a by a.city into c
              select new
              {
                  quantity = c.Count(),
                  city = c.Key
              }).OrderByDescending(a => a.quantity).Select(a => a.city);

var cityCollection = new List<string>();
foreach (var city in cities)
    cityCollection.Add(city.ToString());

I have tried withou success

var cities = (from oa in db.offer_address
                    from of in db.offer.Where(x => x.identifier == oa.identifier)
                    from ad in db.address.Where(y => y.identifier == oa.offeridentifier).AsEnumerable()
                group ad.city by new { ad.city } into g
                select new
                {
                    quantity = g.Count(),
                    city = g.Key
                }).OrderByDescending(a => a.quantity);

The problem occurs when try to get inside the first loop!

Unknown column 'GroupBy1.K1' in 'field list'`

Line 55: foreach (var city in cities)`

With the second case:

Can't group on 'A1'

UPDATE

This code works, but its not i need

var cities = (
                    from of in db.offer
                    from ad in db.address
                    from oa in db.offer_address
                    where (of.identifier == oa.offeridentifier && ad.identifier == oa.addressidentifier)
                group ad.city by new { ad.city } into g
                select new
                {
                    quantity = g.Count()
                }).OrderByDescending(a => a.quantity)

Or

var cities = (
                    from of in db.offer
                    from ad in db.address
                    from oa in db.offer_address
                    where (of.identifier == oa.offeridentifier && ad.identifier == oa.addressidentifier)
                group ad.city by new { ad.city } into g
                select new
                {
                    city = g.Key
                });
  • 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-24T01:40:58+00:00Added an answer on May 24, 2026 at 1:40 am

    Update – Try adding AsEnumerable() after the first select

    var query = (from o in db.offer
                from a in db.address
                from oa in db.offer_address
                where (o.identifier == oa.offeridentifier && a.identifier == oa.addressidentifier)
                group a by a.city into c
                select new
                {
                   quantity = c.Count(),
                   city = c.Key
                })
                .AsEnumerable()
                .OrderByDescending(a => a.quantity)
                .Select(a => a.city);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started using ModX yesterday. Prepared my multilingual website using this tutorial: http://www.multilingual-modx.com/blog/2011/multilingual-websites-with-modx-and-babel.html .
I just started a new job yesterday and this is only my second job
Yesterday I started to develop with Phonegap. I downloaded phonegap and xCode 4.3 from
I've just started learning how to use pygame yesterday. I was read this one
I am very, very new with MVC (just started yesterday) so this question is
I have this huge system started running yesterday. Thousands of people connecting simultaneously.. I'm
I'm started looking at Subsonic just yesterday and having trouble figuring out how to
Yesterday's Wikibender that started with this stackoverflow qestion on Comonads ended up at MarkCC's
I am fairly new to using infragistics controls (started yesterday). While they are (very)
I started dabbling in groovy yesterday. There's an example on the groovy website that

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.