SELECT [UserId] FROM [TU_LMS].[dbo].[MstUser] where RoleId in (3,5)
Loading
SELECT [UserId] FROM [TU_LMS].[dbo].[MstUser] where RoleId in (3,5)
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tuhin PaulPosted Mar 20, 2023, 12:53 AM
LINQ code filters the MstUser table by checking if the RoleId column is contained in the roleIds list and then selects the UserId column. The equivalent SQL query uses the IN operator to filter the MstUser table by checking if the RoleId column is in the list of values (3, 5) and selects the UserId column.
Tuhin PaulPosted Mar 18, 2023, 12:57 PM
If you only need the UserId column, you can modify the Select() clause to only select that column. This can reduce the amount of data that needs to be retrieved from the database, which can improve performance.
Rajeesh MenothPosted Mar 18, 2023, 7:48 AM
Hi,
Try this:
Manikandan MurugesanPosted Mar 18, 2023, 5:33 AM
you can write the equivalent LINQ query for the above SQL query as follows:
Here,
dbis an instance of the DataContext class representing your database context.Alternatively, you can use the lambda syntax for the same query:
This will give you a collection of
UserIds that match the condition specified in the SQL query.Raj BhattPosted Mar 18, 2023, 4:57 AM
Uday DodiyaPosted Mar 18, 2023, 4:53 AM
Hi,
you can write linq query as per below
Option 1
Option 2
Naimish MakwanaPosted Mar 17, 2023, 3:14 PM
You can use below:
Thanks