Skip to main content

Understand the LinQ Syntax in Automation


LINQ means Language Integrated Query. Import the System.Linq namespace and it provides many extension methods.

LINQ enables you to query data from a SQL Server database, XML, in-memory arrays and collections, ADO.NET datasets, or any other remote or local data source that supports LINQ.

We are going to understand the basic Syntax of LINQ query to Filter One Column of Excel.

For Example: We have an Excel Sheet, which we already read by using activity 'Read Range in UiPath' then all the data come into DataTable ( Display Info in Tabular form Or Combination of Rows and Columns)

DataTable.Select.Where(Function(x) x.Item("ColumnName").ToString.Trim.ToLower.Equals("y"))

Now, Let's understand this LinQ query step by step:
  • DataTable: The Excel you read comes into DataTable variable.
  • Select: It Defines the results to return from the Query.
  • Where: Specifies the Filtering Condition for the Query.
  • Function(x): An anonymous (unnamed) function that can be passed around as a variable or as a parameter to a method call.
  • x.Item("ColumnName"): Particular Column Name or Index to put filtration condition on.
  • Trim: Remove the Spaces from Start and End.
  • ToLower: Converts the characters into lower case (like LINQ >>> linq)
  • Equals: Condition for Exact Match.

For Reference you can also refer this Link for more queries: LinQ

Comments

Post a Comment