I am trying to get the latest version of a program in C #. The code below is the only way I was able to get the code to run in my controller without errors:
PList = PList.Where(x => x.PSP == LP && x.VERSION == "1.3");
The problem is that if I do not support this code through each new version and do not fix it in the code for the latest version, it will not work correctly.
So, I thought that I could use the maximum function to get the latest version, but this is varchar in SQL DB, and I canβt change it, since I donβt have access to change types.
I tried different ways to do this, as an example below, with no luck.
PList = PList.Where(x => x.PSP == LP && x.VERSION.MAX());
The && 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 the PSP LP matches And is this the highest version in the database? Thanks for the help!
Update
Thanks to everyone for the excellent answers, and I see how some of them can work independently, but none of them worked with the code that I have. I think publishing the rest of the code can help make diagnosing the problem 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(); }
source share