Click here to Skip to main content
15,921,210 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every body


I need to select some first rows from a table by LINQ that has bellow condition:

Sum(NumberColumn) < SpecificNumber

For example:

IF(SpecificNumber == 40)
Show(3 first Rows) => because 10 + 5 + 20 < 40 But 10+5+20+15 > 40

or

IF(SpecificNumber == 20 )
Show(2 first rows) => because 10 + 5< 20 But 10+5+20 > 20

ID	Title	Number
1	X	10
2	Y	5
3	W	20
4	Z	15


Thank you for attention
Posted

1 solution

Hi

in this situation you must use from TakeWhile method.

I hope it's help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900