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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:20:21+00:00 2026-05-28T15:20:21+00:00

I have the following C# LINQ code : List<myProductList> qMain = ( from m

  • 0

I have the following C# LINQ code :

List<myProductList> qMain = (
 from m in db.ProductsList.OrderByDescending 
                              (it => it.GroupCode == 1 || it.L1 == 1)
 where m.GoodCode == 1 || m.L1 == 1
 select new myProductList
 {
     StackAmount = m.StackAmount,
     GoodCode = m.GoodCode,
     PrivateCodeForSort = m.PrivateCodeForSort,
     GoodMainCode = m.GoodMainCode,
     MaxSellPrice = m.MaxSellPrice,
     SellPrice5 = m.SellPrice5,
     SellPriceType = m.SellPriceType,
     GoodExplain1 = m.GoodExplain1,
     Writer = m.Writer,
     DragoMan = m.DragoMan,
     GoodName = m.GoodName,
     Printing = m.Printing,
     CoverType = m.CoverType,
     PrintYear = m.PrintYear,
     PrintPeriod = m.PrintPeriod,
     Creation = m.CreationDate
 }).Take(50).ToList();

I have a kind of serious problem, The ProductList table is a very big and I don’t want to transfer all rows from my database server so I solve this problem by taking 50 rows which is my necessary but the problem is I want to order by descending first of all and then take 50 rows but this code first take 50 rows by ascending and then order by decending only those 50 rows that has already transferred and sorted. how I can fix 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-05-28T15:20:22+00:00Added an answer on May 28, 2026 at 3:20 pm

    No, the code you’ve given:

    • Orders the results
    • Filters the results
    • Projects the results
    • Limits the results to 50

    … in that order.

    On the other hand, it’s a slightly odd OrderByDescending call to start with. If you want a different ordering applied as well you could easily do that too – for example:

     from m in db.ProductsList
     orderby (it.GroupCode == 1 || it.L1 == 1) descending, it.SellPrice5 descending
     where m.GoodCode == 1 || m.L1 == 1
     select new myProductList
     ... // code as before
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method that contains the following Linq to SQL code: public List<L2SBusinessEntities.Report.MesReport>
I have the following code which builds a Generic List of Abc from a
I am reletively new to Entity Framework and LINQ. I have the following code
I have the following code: List<string> result = new List<string>(); foreach (string file in
I have the following code: var personIds = from player in myPlayers select player.person_id;
If I have the following Linq code: context.Table1s.InsertOnSubmit(t); context.Table1s.InsertOnSubmit(t2); context.Table1s.InsertOnSubmit(t3); context.SubmitChanges(); And I get
I have the following code: using System; using System.Linq; using System.Linq.Expressions; public class Program
I have the following linq query (applied to the Northwind database) (from od in
I have the following LINQ query: List<string> Types = (List<string>)Directory.GetFiles(@C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727) .Where(x => System.IO.Path.GetFileNameWithoutExtension(x).Contains(Microsoft)) .ToList<string>();
I have this following IEnumerable LINQ query: var query = from p in Enumerable.Range(2,

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.