I’m triying to assign the actual date to the empty values using LINQ. I have an assign activity with this code but I’m confused with the structure of the if condition.
(From d In dt_input.AsEnumerable
Let ra= New Object(){
d(0),
If(String.IsNullOrEmpty(d(1).toString),
d(1),
DateTime.Now.ToString(“dd/MM/yyyy”))
}
Select dt_result.Rows.Add(ra)).CopyToDataTable
Hi,
There are a lot of ways to do it, for example and update can be one, but this link sorry but don’t help me because there isn’t any example of an if condition case with LINQ.
Thnks.
we gave you the feedback that your targeted approach is not recommended and the tried syntax is against the LINQ nature used within an assign.
passing the filtered rows to the for each activity | typeargument: datarow
frow| values: dtData.AsEnumerable.Where(Function (x) isNothing(x("Date")) orElse String.IsNullOrEmpty(x("Date").toString.Trim))
within the for each, we do update:
frow(“Date”) = now.toString(“dd/MM/yyyy”)
Okey, I’m trying to do it and works fine but I have a question.
In my Excel the column date is on the E position, and I’m triying to set the same code but changing the numbers, because I want to set the date on the column E too.
I’m using this number position:
(From d In dt_input.AsEnumerable
Let ra= New Object(){
d(0),
If(String.IsNullOrEmpty(d(4).toString),
d(4),
DateTime.Now.ToString(“dd/MM/yyyy”))
}
Select dt_result.Rows.Add(ra)).CopyToDataTable