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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:46:10+00:00 2026-06-10T05:46:10+00:00

I am trying to get the latest version of a program in C#. The

  • 0

I am trying to get the latest version of a program in C#. The code below is the only way I have been able to get the code to run in my controller without any errors:

PList = PList.Where(x => x.PSP == LP && x.VERSION == "1.3");

The problem is unless I maintain this code through every new version and correct it in the code to the most current version it will not work correctly.

So I thought that I could use a max function to get the latest version but it is a varchar in the SQL DB and I cannot change it since I do not have the access to change types.

I have tried different ways of doing this like the example below with no luck.

PList = PList.Where(x => x.PSP == LP && x.VERSION.MAX());

Operator ‘&&’ cannot be applied to operands of type ‘bool’ and ‘char’

So how can I get the Max version when I need to know if PSP is equal to LP AND the version is the highest number in the DB? Thank you for your help!

Update

Thank you all for your excellent answers and I can see how some of them might work on their own but none of them have worked with the code I have. I think posting the rest of the code might help make diagnosing the issue a little easier, so here is the rest of the code.

public virtual ActionResult getAjaxP(string TP = null)
{
    if (TP != null)
    {
        var PList = from x in db.iamp_mapping select x;
        PList = PList.Where(x => x.PSP == TP);
        return Json(PList.Select(x => new { x.PS }).Distinct().ToArray(), JsonRequestBehavior.AllowGet);
    }
    return View();
}
  • 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-10T05:46:11+00:00Added an answer on June 10, 2026 at 5:46 am

    You could take advantage of the System.Version class.

    var maxVersion = PList
        .Select(x => new Version(x.VERSION))
        .Max()
        .ToString();
    
    PList = PList.Where(x => x.PSP == LP && x.VERSION == maxVersion);
    

    This will favor “1.11” over “1.3”, for instance.

    If this is Linq-to-Sql, it might involve an extra call to the database.

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

Sidebar

Related Questions

I have been trying to get the latest version of phpmailer from here: http://sourceforge.net/projects/phpmailer/files/
Im trying to use msbuild to get the latest version of my code from
I'm trying to get a bit of code working. I'm using xfade, latest version.
I've been trying to get a hyde site going using the latest version available
I have this query, and I am trying to get the latest comment for
I downloaded the latest version of Boost and I'm trying to get the Boost.python
I am trying to get the swiping to work for Cocos2d latest version here
I'm trying to get the latest version of TFS using Team Foundation Server API.
I have been trying to get slimv (http://www.vim.org/scripts/script.php?script_id=2531) working for a while now, but
I'm trying to find a way to merge shelve changes with the latest version

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.