How To Find Ids between Two Ids in A List using LINQ or LambdaExpression [Resolved]

Posted by Kasani007 under LINQ on 6/8/2016 | Points: 10 | Views : 558 | Status : [Member] | Replies : 4
How To Find Ids between Two Ids in A List using LINQ or LambdaExpression




Responses

Posted by: Rajnilari2015 on: 6/9/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
@Kasani007 Sir,

Please try this

var intList = new List<int>() { 1, 2, 3, 4, 4, 5, 6, 7, 8 };

int startID = 4;
int endID = 7;

//LINQ way
var find = (from item in intList where item > startID && item < endID select item).ToList();

//LAMBDA way
var find = intList.FindAll(f => f > startID && f < endID);


Result
-------
5
6

--
Thanks & Regards,
RNA Team

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sheonarayan on: 6/8/2016 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Here is your query.

var result = from db.Projects.Where(d => d.AutoId >= minValue && d.AutoId <= maxValue)

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Amatya on: 6/9/2016 [Member] Silver | Points: 25

Up
0
Down
nIce 1

Feel free to share informations 9731764134
mail Id ' adityagupta200@gmail.com
Thanks

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muneshs16 on: 6/11/2016 [Member] Starter | Points: 25

Up
0
Down
var result = dbContext.tabelName.Where(d => d.id>= minValue && d.id<= maxValue).ToList()


Munesh

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response