Questions tagged [sql-to-linq-conversion]

Use this tag for questions related to the conversion of SQL statements into LINQ statements.

224 questions
-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…
-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…
user2919288
  • 27
  • 2
  • 7
-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
  • 3,619
  • 4
  • 38
  • 53
-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
  • 63
  • 2
  • 5
-3
votes
1 answer

SQL to LINQ conversion of query with multiple group by and count

Please provide with the conversion of below SQL query to LINQ SQL Query converted to LINQ Query : Required SQL to LINQ Conversion of below SQL query select COUNT(rg.TagId), t.Name, r.Id,r.Name from ResourcesTag rg inner join Tag t…
-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
  • 5
  • 5
-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
  • 153
  • 1
  • 13
-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
  • 119
  • 1
  • 10
-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. …
Animesh Ghosh
  • 41
  • 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,691
  • 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…
-4
votes
1 answer

Converting SQL to Linq ("WHERE EXISTS")

Can anyone help me to convert this SQL into LINQ? SELECT * FROM Room_Type b WHERE Exists( SELECT * FROM Room a WHERE a.RoomId NOT IN (SELECT r.RoomId FROM Reservation r WHERE NOT (r.DepartureDate<='2015-02-16' OR r.ArrivalDate >…
-4
votes
1 answer

How to perform multiple joins in LINQ

I have a stored procedure that I'm converting to LINQ, but I'm a little stuck. Here's the SQL: select @name = tp.Name , @Entity = tc.Entity , @Name …
Naruto
  • 8,950
  • 32
  • 110
  • 191
-4
votes
1 answer

if condition in IQueryable Join in LINQ query (Convert SQL to LINQ)

As I need to convert following MS SQL Query in to Linq in C# As I have tryed with IQueryable but not able to do . As in that we need to check if condition is true then only need to go for join with table Thanks in adv. SELECT @sqlQuery = 'SELECT…
BJ Patel
  • 5,771
  • 11
  • 42
  • 78
1 2 3
14
15