LINQ Query for Sum of All rows with Some Specific conditions

Consider a Employ Table with Schema
1.Employ Name
2.Employ Salary
3.Employ Age
4.Country

i am trying to get the Sum of all Employess whose age greater than 30 and who belongs to “UK” country using LINQ Queries can Some one Help me on this

Hi,

Do you need Sum of salary of the specific rows? If so, the following will work.

dt.AsEnumerable.Where(Function(r) Int32.Parse(r("Employ Age").ToString)>30 AndAlso r("Country").ToString="UK").Sum(Function(r) Decimal.Parse(r("Employ Salary").ToString))

This return Decimal type. If you need other type, please modify Decimal.Parse part (like Double.Parse etc.)

Regards,

Thank you @Yoichi its working
Can you Please alos suggest me how to learn the LINQ queries from Simple to complex queries

Check this link

or this

cheers

Hi,

FYI, the following also helps you if use LINQ in UiPath.

Regards,