Query in Linq Query

I was watching a linq tutorial video and following his steps

His linq query looked like this


The purpose of this query is to remove rows whose Country column is empty

I followed his same steps and same query but I am getting an error

Can anyone let me the reason for this error, it would be very helpful.

@Mohammad.Fuad

Left side: dtFiltered (a new DataTable variable)=
YourDataTableVar.AsEnumerable().Where(Function(row) Not String.IsNullOrEmpty(row(“Country”).ToString.Trim)).CopyToDataTable

Please try this

When I used your linq, I got this error
linq2

Try this @Mohammad.Fuad
(
From row In dt_1
Where Not String.IsNullOrEmpty(row(“Country”).ToString)
Select row).copyToDataTable

1 Like

getting same error
linq2

@Mohammad.Fuad

type the expression manually don’t copy and paste it

(
From row In dt
Where Not String.IsNullOrEmpty(row(“country”).tostring)
Select row
).copytodatatable

cheers

1 Like

@Mohammad.Fuad

1 Like

Thanks a lot dude, it worked.

can you tell me why that error occurs?

1 Like

Hi @Mohammad.Fuad

Try with expression

(
From row In dt_1
Where Not String.IsNullOrEmpty(row("Country").ToString)
Select row).copyToDataTable

For this error you need to re enter the Double quote in the expression

Regards
Gokul

1 Like

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