Edit LINQ

If I want add condition about column “Chk Dup” equal blank.

How to edit code as below.

InputDT.AsEnumerable.Where(Function(x)x("Status (1)").ToString.ToLower.Equals("complete") and Cint(x("Count")) >= 15 and DateTime.ParseExact(x("Issue Date").ToString.Trim,"yyyyMMdd",System.Globalization.CultureInfo.InvariantCulture).AddYears(-543)<= ApproveDate andAlso String.IsNullOrWhiteSpace(x("Status").ToString)).ToArray
1 Like

Hi @fairymemay ,

Try this -

InputDT.AsEnumerable.Where(Function(x)x(“Status (1)”).ToString.ToLower.Equals(“complete”) and Cint(x(“Count”)) >= 15 and String.IsNullOrEmpty(“Chk Dup”).ToString and DateTime.ParseExact(x(“Issue Date”).ToString.Trim,“yyyyMMdd”,System.Globalization.CultureInfo.InvariantCulture).AddYears(-543)<= ApproveDate andAlso String.IsNullOrWhiteSpace(x(“Status”).ToString)).ToArray

Thanks

1 Like

Hi

You are almost done

Just within the bracket atlast metion this

AND String.IsNullOrEmpty(x(“Chk Dup”).ToString.Trim)

So the overall expression will be like this

InputDT.AsEnumerable.Where(Function(x)x(“Status (1)”).ToString.ToLower.Equals(“complete”) and Cint(x(“Count”)) >= 15 and DateTime.ParseExact(x(“Issue Date”).ToString.Trim,“yyyyMMdd”,System.Globalization.CultureInfo.InvariantCulture).AddYears(-543)<= ApproveDate andAlso String.IsNullOrWhiteSpace(x(“Status”).ToString)
AND String.IsNullOrEmpty(x(“Chk Dup”).ToString.Trim)
).ToArray

You can add multiple condition like this with a AND operator in the middle

Cheers @fairymemay

1 Like

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