Need Linq Query for SQL Query

Im trying to understand how to write Linq query, can i please get linq queries for the below 2 SQL quries???

SELECT TOP 25
cs-uri-stem as URL,
MAX(time-taken) As Max,
MIN(time-taken) As Min,
Avg(time-taken) As Average
FROM ’[LOGFILEPATH]’
GROUP BY URL
ORDER By Average DESC

SELECT
sc-win32-status As Win32-Status,
WIN32_ERROR_DESCRIPTION(sc-win32-status) as Description,
COUNT(*) AS Hits
FROM ’[LOGFILEPATH]’
WHERE Win32-Status<>0
GROUP BY Win32-Status
ORDER BY Win32-Status ASC

@Mahesh_Nag In your Second Query, Is WIN32_ERROR_DESCRIPTION a function ?

Sorry about that. Can you plz let me know about how to extract top 25 records and also how to apply where clauses(WHERE Win32-Status<>0) ??

Updated Query:
SELECT
sc-win32-status As Win32-Status,
COUNT(*) AS Hits
FROM ’[LOGFILEPATH]’
WHERE Win32-Status<>0
GROUP BY Win32-Status
ORDER BY Win32-Status ASC

@Mahesh_Nag Check this Workflow :
Sequence6.xaml (7.2 KB)

To Get Only Top 25 records from the Datatable, You can use this Syntax:
yourDatatableVariable.AsEnumerable.Take(25).ToArray.CopyToDatatable

2 Likes

Works perfectly fine, thanks

1 Like

Do u have any reference Document/Link/Guide for writing Linq in Uipath as its quite different from usual Linqs???

@Mahesh_Nag I guess an UiPath Guide for Executing Linq Query’s need to be made. :sweat_smile:

You can Check this link :

https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/linq/introduction-to-linq

Although the Syntax might be a little different when compared to Executing Linq in UiPath , The Logic and working is Same, and we can Implement the same from Visual Basic Linq to UiPath Linq.

You just need to understand what kind of Syntax is used in UiPath and what Syntax is used in Visual Basic.

1 Like

Thanks :slight_smile:

1 Like

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