Use this tag for questions related to the conversion of SQL statements into LINQ statements.
Questions tagged [sql-to-linq-conversion]
243 questions
-1
votes
1 answer
Change sql query to LINQ
How I convert this sql query :
Select ID, first_name, last_name, phone_number, room_type, room_floor, room_number, break_fast, lunch, dinner, cleaning, towel, s_surprise, supply_status, food_bill
from reservation
where check_in = '" + "True" + "'…

Ghofran Shorbagy
- 3
- 2
-1
votes
2 answers
Convert T-SQL with MIN Function to LINQ
Can you help me to convert SQL to LINQ:
select empno, dd, Min(sdate) sdate from TransactionPoolView
where sdate >= '" & DateValue(sdate) & "' and sdate < '" & DateValue(edate + 1)
group by empno, dd

user3451498
- 1
- 1
-1
votes
1 answer
Convert Count ... Group By From SQL Query To LINQ
Please help me convert the MSSQL below to LINQ.
SELECT A.id, A.type, COUNT(IIf(B.BookId IS NOT NULL, 0, null)) AS TotalCount
FROM Store A
LEFT JOIN Book B ON A.id = B.id
GROUP BY A.id, A.type;
I currently have this LINQ code:
from a in Store
join b…

user2402624
- 211
- 1
- 4
- 10
-1
votes
2 answers
SQL to LINQ orderby specific order
select Priority,
case Priority
when 'Medium' then (Count(*)* 100 / (Select Count(*) From #tem where Priority = 'Medium'))
when 'High' then (Count(*)* 100 / (Select Count(*) From #tem where Priority = 'High'))
when 'Low' then…

Rajat Suneja
- 494
- 2
- 10
- 27
-2
votes
2 answers
I need to convert sql to Linq
This is my sql command:
select
b.Brand,
count(b.Brand) as BrandCount,
SUM(a.Qty) as DeviceCount
from (
select * from DeviceList
) as a
join DeviceMaster as b
on a.DeviceMasterId = b.Id
group by b.Brand
Here is what I've…

aakash kumar
- 13
- 1
-2
votes
1 answer
Sql code convert into Entity Framework
I need to covert that sql code into ADO.net entity framework code please need some one help because i am new to the mvc asp.net .
Thnaks
SELECT A.cid, A.cname,
B.sid, B.lname,B.fname,
C.section,c.crn
FROM courses A, students B, sections…

DilW
- 27
- 2
- 8
-2
votes
2 answers
How to use Inner Join and Except in Linq EntityFramework 4
I have two tables with a one (Parent) to many (Details) relationship.
I would like to write this query (which is written in SQL) in Linq. As you see; it is an inner join on a subquery, which contains Except:
select pa.* from dbo.Parent pa
inner…

t_plusplus
- 4,079
- 5
- 45
- 60
-3
votes
1 answer
SQL Server STRING_AGG() : equivalent in Linq
This is my table tbl_emp:
This is the result I need:
In SQL Server 2017, I can use STRING_AGG to get the desired result:
SELECT
name,
STRING_AGG(email,'') 'email', STRING_AGG(email2,'') 'email2'
FROM
tbl_emp
GROUP BY
name
How…

TaKaNa
- 19
- 2
-3
votes
1 answer
Convert SQL query into linq C#
Convert SQL query to LINQ C#
SELECT ts.TeacherId, count(Distinct ts.SubjectId) as Subjects
from dbo.TeacherSubjects ts
GROUP BY ts.TeacherId
HAVING ts.TeacherId = 2352
here is my LINQ query
var SubjectsGroup = db.TeacherSubjects.Where(p =>…

Jon
- 71
- 1
- 2
- 6
-3
votes
1 answer
Need Equivalent LINQ Query for the following SQL Server Query
I am looking for the equivalent LINQ query for the following Query.
SELECT SUM (Cost) FROM [Vulpith_Test2].[dbo].tbl_MilestonesForOngoingSeeker]
WHERE ([Post_Title_ID] = '3251'
and [List_Title_ID]='1180')
and (PaymentStatus='1' or…

Madhu
- 15
- 8
-3
votes
1 answer
What is the exact LINQ Query for this SQL Query?
i am very new in LINQ so,I can't understand what the exact Linq query is of this SQLquery.
Please give exact Linq Query similar to this SQL query.
Select * From tblProduct
Where ProductId In
(Select ProductId from tblViewer Where…

Sk Asraf
- 163
- 2
- 14
-3
votes
2 answers
Sql Query to Linq Query
I have written an sql qyery like
SELECT TOP 1000
[tlotWeight]
,[TEU]
,[SeaAirFlag]
,CASE
WHEN [SeaAirFlag]='SEA' OR [SeaAirFlag]='Sea'
then [TEU]
else [tlotWeight] end as Volume
FROM [LogisticsBI].[dbo].[GoldenVolume]
I want it…

gaup
- 129
- 1
- 11
-3
votes
1 answer
Request for LINQ query
I have a sql query. Please someone help me to convert it into LINQ.
select * from ProductOrder where OrderId != (Select OrderId from OrderEvents) and MemberId=2
I write this code. But tis is not working. please help me.
…

Sanjay Sharma
- 43
- 2
- 8
-3
votes
2 answers
Convert t-sql query to linq
I have this t-sql query and I need to convert it to linq
SELECT m.field1
FROM table1 m
Join table2 v on v.field1 = m.field1 and v.field2 = m.field3
WHERE v.field4 =4
AND m.field1=125325
…

Amr Elnashar
- 1,739
- 12
- 33
- 53
-4
votes
1 answer
linq queries in train database
I have a train database, with all required fields such as Train, Route, Station, Passenger, Reservation etc. I want to get trains between a pair of stations using LINQ(I know the SQL Query, but I am unable to convert it to LINQ). Please anyone help…

Sourodeep Chatterjee
- 199
- 3
- 9