# Linq error

**URL:** <https://forum.uipath.com/t/linq-error/207549>\
**Category:** Help\
**Created:** [March 31, 2020, 11:40am UTC](https://forum.uipath.com/t/linq-error/207549 "2020-03-31T11:40:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![amruta\_pawar](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/amruta_pawar/32/60289_2.png) [@amruta\_pawar](https://forum.uipath.com/u/amruta_pawar)\
**Post date:** [March 31, 2020, 11:40am UTC](https://forum.uipath.com/t/linq-error/207549/1 "2020-03-31T11:40:18Z")

</div>

Hi guys,

I am not good in linq , so below is my try for distinct records , please correct me.

dtResult.AsEnumerable.GroupBy(Function(x) new with {Key.a=x(“Customer Account”).ToString,Key.b=x(“Company Code”).ToString,Key.c=x(“Frequency”).ToString,Key.d=x(“Start Date”).ToString,Key.e=x(“End Date”).ToString,Key.f=x(“Email contact”).ToString} into grp=Group Select grp.First()).CopyToDatatable()

I am getting error as ,  
 ![image](https://global.discourse-cdn.com/uipath/original/3X/4/7/479bcadd13bb1935c10b59a09d235bc27f51cff0.png)

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [March 31, 2020, 11:45am UTC](https://forum.uipath.com/t/linq-error/207549/2 "2020-03-31T11:45:09Z")

</div>

@amruta_pawar Try this query :  
dtResult.AsEnumerable.GroupBy(Function(x) new with {Key.a=x(“Customer Account”).ToString,Key.b=x(“Company Code”).ToString,Key.c=x(“Frequency”).ToString,Key.d=x(“Start Date”).ToString,Key.e=x(“End Date”).ToString,Key.f=x(“Email contact”).ToString}).Select(Function(g)g.First).CopyToDatatable

---

<div class="post-metadata">

**Author:** ![amruta\_pawar](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/amruta_pawar/32/60289_2.png) [@amruta\_pawar](https://forum.uipath.com/u/amruta_pawar)\
**Post date:** [March 31, 2020, 12:03pm UTC](https://forum.uipath.com/t/linq-error/207549/3 "2020-03-31T12:03:06Z")

</div>

Thank you so much it worked

---

<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:** [April 3, 2020, 12:03pm UTC](https://forum.uipath.com/t/linq-error/207549/4 "2020-04-03T12:03:06Z")

</div>

Closed on April 3, 2020, 12:03pm UTC

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