SELECT Row_Number() over (order by Id desc) SrlNo,*
FROM [TU_LMS].[dbo].[ContentDetails] where DeptId=28 and createdBy=6
union
SELECT Row_Number() over (order by Id desc) SrlNo ,*
FROM [TU_LMS].[dbo].[ContentDetails] where DeptId=28 and createdBy !=6
Loading
Amit MohantyPosted Feb 20, 2023, 4:22 AM
check this
Jignesh KumarPosted Feb 19, 2023, 5:26 AM
Hello Sandeep,
Please use this one,
try this one,
Tuhin PaulPosted Feb 18, 2023, 5:42 AM
Sandeep , replying bit late on this, see this code is of any help.:
TO generate row numbers in LINQ see below:
In this example, the ContentDetails table is queried and filtered by DeptId. The results are then ordered by Id in descending order, and projected using a combination of the Select method and a lambda expression that includes the Row_Number calculation. The results are then split into two sets based on the CreatedBy property, and finally, the two sets are unioned together to form the final results.
Naimish MakwanaPosted Feb 17, 2023, 8:34 AM
Hello Sandip,
use below solution.
Thanks
Naimish
Sandeep KumarPosted Feb 17, 2023, 8:25 AM
Actually i want 1st ContentDtlsUserWise data then contentListall in sequence order
var ContentDtls= ContentDtlsUserWise.Union(contentListall).ToList()
Vishal JoshiPosted Feb 17, 2023, 8:05 AM
Hello Sandeep,
Please try IEqualityComparer to get union of object data and get row number with the same. please check below sample code.
Output:
rowNumber: 1 Data: 1
rowNumber: 2 Data: 2
rowNumber: 3 Data: 3
rowNumber: 4 Data: 4
rowNumber: 5 Data: 5
rowNumber: 6 Data: 6
rowNumber: 7 Data: 8
rowNumber: 8 Data: 9
rowNumber: 9 Data: 10
Thanks
Naimish MakwanaPosted Feb 17, 2023, 7:54 AM
try this.
Sandeep KumarPosted Feb 17, 2023, 7:41 AM
After Union I want Srl No ,but how
var ContentDtls= ContentDtlsUserWise.Union(contentListall).ToList()
Naimish MakwanaPosted Feb 17, 2023, 7:17 AM
Hello Sandeep,
Try this.
Thanks
Naimish Makwana
Jignesh KumarPosted Feb 17, 2023, 7:17 AM
Hello Sandeep,
Please use below query,