# Linq giving error

**URL:** <https://forum.uipath.com/t/linq-giving-error/664229>\
**Category:** Studio\
**Tags:** workflow-diff, question, studio\
**Created:** [October 27, 2023, 9:48am UTC](https://forum.uipath.com/t/linq-giving-error/664229 "2023-10-27T09:48:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yash.choursia](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yash.choursia/32/366204_2.png) [@yash.choursia](https://forum.uipath.com/u/yash.choursia)\
**Post date:** [October 27, 2023, 9:48am UTC](https://forum.uipath.com/t/linq-giving-error/664229/1 "2023-10-27T09:48:14Z")

</div>

Hi Team,

I have written the linq and an error is occuring. Is it due to the datatable which is obtained after the linq is null?

 ![image](https://global.discourse-cdn.com/uipath/original/4X/1/c/7/1c7c5203a1db09cfaba499b199d7a09e8c7cfbc8.png)

After the Linq, the Original\_DT may have been empty i guess. What is the solution for this?

---

<div class="post-metadata">

**Author:** ![Shiva\_Nikhil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/shiva_nikhil/32/267408_2.png) [@Shiva\_Nikhil](https://forum.uipath.com/u/Shiva_Nikhil)\
**Post date:** [October 27, 2023, 9:52am UTC](https://forum.uipath.com/t/linq-giving-error/664229/2 "2023-10-27T09:52:25Z")

</div>

@yash.choursia

use this query in place

> array\_dt=dt.AsEnumerable.Select(Function(r) r(“InvoiceNo”).ToString).where(Function(x) not VL02N\_List.Contains(x.ToString)).ToArray

use if condition as

> array\_dt.count\>0

then

array\_dt.copytodatatable

else

use log message

---

<div class="post-metadata">

**Author:** ![Unnathi\_Bhat](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/unnathi_bhat/32/268649_2.png) [@Unnathi\_Bhat](https://forum.uipath.com/u/Unnathi_Bhat)\
**Post date:** [October 27, 2023, 9:55am UTC](https://forum.uipath.com/t/linq-giving-error/664229/3 "2023-10-27T09:55:40Z")

</div>

check using below code in  
if condition  
OriginalFile\_DT.AsEnumerable.Any(Function(x) Not VL02N\_List.Contains(x(“InvoiceNo.”).ToString))  
Then part keep the assign activity  
OriginalFile\_DT.AsEnumerable.Where(Function(x) Not VL02N\_List.Contains(x(“InvoiceNo.”).ToString)).CopyToDatatable  
Else  
Log message or steps to follow if there are no rows matching your condition

---

<div class="post-metadata">

**Author:** ![neha.upase](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/neha.upase/32/402674_2.png) [@neha.upase](https://forum.uipath.com/u/neha.upase)\
**Post date:** [October 27, 2023, 10:18am UTC](https://forum.uipath.com/t/linq-giving-error/664229/4 "2023-10-27T10:18:38Z")

</div>

Hi, please check variable Original\_DT has data or not and check column names are correct.

---

<div class="post-metadata">

**Author:** ![Gokul001](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gokul001/32/462734_2.png) [@Gokul001](https://forum.uipath.com/u/Gokul001)\
**Post date:** [October 27, 2023, 10:32am UTC](https://forum.uipath.com/t/linq-giving-error/664229/5 "2023-10-27T10:32:17Z")

</div>

Hi @yash.choursia

Check out the thread

> [@ambulance sos \[FirstAid\] Handling of The source contains no DataRows exception](https://forum.uipath.com/t/firstaid-handling-of-the-source-contains-no-datarows-exception/410526):
>
> This FirstAid Tutorial will describe how a the source contains no DataRows EXCEPTION can be handled. Introduction Let’s have a look at the following filter data table scenario: Name CCode Tom US Charlotte FR Seema IN Jean FR Assignment: Filter all rows on a particular Country Code like FR, UK, ES, UK… Ensure that all CCode data column values are trimmed Ensure that the Filter check is case insensitive we can implement it e.g. with the help of a LINQ statement: dtData.AsE…

Video : [https://www.youtube.com/watch?v=ioxPUw\_PxMk](https://www.youtube.com/watch?v=ioxPUw_PxMk)

You can also try with `Try Catch` activity

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [October 30, 2023, 10:33am UTC](https://forum.uipath.com/t/linq-giving-error/664229/6 "2023-10-30T10:33:11Z")

</div>

Closed on October 30, 2023, 10:33am UTC

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