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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:40:49+00:00 2026-05-20T18:40:49+00:00

var metroquery = (from metro in objCommon.Lst_Cities where (SqlMethods.Like(metro.CityNM, Mumbai) || SqlMethods.Like(metro.CityNM, Delhi )||

  • 0
var metroquery = (from metro in objCommon.Lst_Cities
where (SqlMethods.Like(metro.CityNM, "Mumbai") ||
SqlMethods.Like(metro.CityNM, "Delhi" )||
SqlMethods.Like(metro.CityNM, "Kolkata") ||
SqlMethods.Like(metro.CityNM, "Chennai") || 
SqlMethods.Like(metro.CityNM, "Bangalore") ||
SqlMethods.Like(metro.CityNM, "Pune") ||
SqlMethods.Like(metro.CityNM ,"Ahmedabad") ||
SqlMethods.Like(metro.CityNM , "Hyderbad"))
select metro).ToList();

     var nonmetroquery = (from metro in objCommon.Lst_Cities
     where !metro.CityNM.Contains("Mumbai") &&
     !metro.CityNM.Contains("Delhi") &&
     !metro.CityNM.Contains("Kolkata") &&
     !metro.CityNM.Contains("Chennai") &&
  !metro.CityNM.Contains("Bangalore") &&
    !metro.CityNM.Contains("Pune") &&
    !metro.CityNM.Contains("Ahmedabad") &&
    !metro.CityNM.Contains("Hyderbad")
    select metro).ToList();

I have written these two Linq queries to retrieve the cities and add the first order of cities i.e. Mumbai and others at top. Second query contains non-metro cities which I want to append to the combo.

Basically I want metro cities at top and non metro below metro cities.

I have used the following code for this:

 List<Lst_City> lstCity1 = new List<Lst_City>();


            foreach (var t in metroquery)
            {

                lstCity1 = metroquery;

            }

            System.Threading.Thread.Sleep(200);

            foreach (var t in nonmetroquery)
            {
                lstCity1 = nonmetroquery;
            }

but I am getting only the non metro cities binded to the ComboBox.

Any help o hint?

  • 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-20T18:40:49+00:00Added an answer on May 20, 2026 at 6:40 pm

    In your foreach method, you are adding the whole list instead of var t.

    Perhaps this would work:

    List<Lst_City> lstCity1 = new List<Lst_City>();
    
                foreach (var t in metroquery)
                {
    
                    lstCity1.Add(t);
    
                }
    
                System.Threading.Thread.Sleep(200);
    
                foreach (var t in nonmetroquery)
                {
                    lstCity1.Add(t);
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var auditAgencyRecords = (from ag in db.Agencies join ara in db.AuditRuleAccounts on ag.Agency_Id equals
var result = from lr in _db.LeaveRequest join th in _db.TotalHourslu on lr.TotalHoursEffect equals
var result = from lr in _db.LeaveRequest join th in _db.TotalHourslu on lr.TotalHoursEffect equals
var q = 'SELECT * FROM stories_comments WHERE story_id=? AND user_id=? ORDER BY created_at
var stringToHighlight = [userinput] // may be any string like foo, bar or .
var listOfStates = from n in _storageStates select n.tag; If n.tag is a string
var MyObj = function(h,w){ this.height = h; this.width = w; } I would like
var q = (from Comments in db.tblBlogComments where Comments.blogID == this.ID orderby Comments.date descending
var candidates = (from l in db.GetLeads(lat, lon, role, radius + 10) orderby l.Distance
var fruit = [apple,pear,pear,pear,banana]; How do I remove all pear fruit from this array?

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.