LINQ Query for using elseif condition

Hai Guys!!

I attempted to use LINQ Query with if and else conditions.
I used a LINQ query using an if condition. That’s working fine, but I don’t know how to use else if conditions in LINQ .

If I get this solution, it will be very useful in my project. Kindly help me to fix this issue.

Thanks in advance.

Hi @Divya_Sadhasivam,

Please check this topic. Using If Condition in LINQ

It should help.

Regards.
Ömer

Hi @Divya_Sadhasivam ,

Did you mean you wanted to use Nested If’s ? Maybe check the below Expression and Let us know if that was the one you’re looking for ?

if(Transaction_Mail.Subject.ToString.ToLower.Contains("hello"),
CPRV.ToString,
If(CPRV.ToString.Contains("hi"),"hi","bye")
)

Hi @Divya_Sadhasivam ,

As per my understand, if you want to do nothing in else part then just mention “Nothing” in else part like below

if(Transaction_Mail.Subject.ToString.ToLower.Contains(“hello”),CPRV.ToString,Nothing)

Thanks,
Rajkumar

Hai @supermanPunch , @RajKumar_DC , @omer.ozturk first of all thanks for your help and support . l try to use nested if using LINQ , using @supermanPunch solution i get the expected result.

Thank you all !!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.