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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:29:15+00:00 2026-06-16T11:29:15+00:00

i have this simple class: public class JDEItemLotAvailability { public string Code { get;

  • 0

i have this simple class:

public class JDEItemLotAvailability
    {
        public string Code { get; set; }
        public int ShortCode { get; set; }
        public string Description { get; set; }
        public string PrimaryUnitCode { get; set; }
        public string BranchPlant { get; set; }
        public string Location { get; set; }
        public string Lot { get; set; }
        public int AvailableQuantity { get; set; }
    }

This DAL method in my BLL returns a list of them:

var returnedLotList = _JDE8dal.GetLotAvailabilityAsList(_lot);

I want to do the following in the returned list and i want to do it in the most “elegant” LINQ way.

I want to check if among the list there is a record that matches specific criteria. I have thought of something like this:

  var query =
      returnedLotList.Where(l => l.AvailableQuantity != 0 && l.BranchPlant == _mcu && l.Location == _locn)
                               .OrderByDescending(l => l.AvailableQuantity);

BUT i want to say that if the above query does not return results i want to take the first of the rest of the list entries.

How can i do that?

  • 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-06-16T11:29:16+00:00Added an answer on June 16, 2026 at 11:29 am

    You can just use DefaultIfEmpty

    //your first query, unaltered
    var query =
          returnedLotList.Where(l => l.AvailableQuantity != 0 && l.BranchPlant == _mcu && l.Location == _locn)
                                   .OrderByDescending(l => l.AvailableQuantity);
    
    var query2 = query.DefaultIfEmpty(returnedLotList.Take(1));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple server code: public class Server { public static void main(String[]
I have this simple event : public class ClassA { public event Func<string, int>
I have this simple code : public class A { int _private=3; public A
I have this simple class: class element{ public int id; public String name; }
I have this simple code: class A { public: string toString() const { return
I have this simple model public class Autor { [Key] int AutorID { get;
I have this simple class: public class DataBag { public string UserControl { get;
I have this simple class public class Position{ int x; int y; Position(int x,int
Given this simple class: class HasBytes { public byte[] Bytes { get; set; }
Say we have this hyper simple class hierchy: public class SomeMath { public int

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.