Home > Net >  How to screen version of the highest file, only 20 points
How to screen version of the highest file, only 20 points

Time:10-04

Select eligible file, in which only need the latest version of the file, now don't know how to get the highest version of the file, I write the condition of, but the results were not reg. Rgl_version==(db) regulations) Where (x=& gt; X.r gl_code==x.r gl_code). Select (x=& gt; X.r gl_version). Max ())

CodePudding user response:

Db. Regulations. Max (x=& gt; X.r gl_version);

CodePudding user response:

See what version defined data types? Conditions on the Max function directly, it supports lambda expressions,

CodePudding user response:

Before or not, and query, no results

CodePudding user response:

To file, or to version?

 var file=db. Regulations 
The Where (... )
OrderByDescending (x=& gt; X.r gl_version)
FirstOrDefault ();

CodePudding user response:

Linq Max can take to the maximum (because the single largest may have multiple)
If you want to get to the largest name
Can use OrderBy sort (code the most simple, the efficiency is relatively low)
Or with Max first to get the maximum, then use the Where maximum screening items (more than if you need to get the maximum value, which is the most useful)
Or traverse the list, select the maximum and the single largest (and most efficient to write the code at most)

CodePudding user response:

The latest version of the creation time should be the biggest of all

CodePudding user response:

What do you want to take first file,
  •  Tags:  
  • LINQ
  • Related