Questions tagged [sql-to-linq-conversion]

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

224 questions
0
votes
1 answer

SQL to LINQ conversion with NOT IN

please form a LINQ query for the mysql query select a.name ,a.amount from acount as a where a.acountid NOT IN (select c.id from saving as c where c.userid="x") and a.userid="x"; X=1; Please help me out Thanks
Anjana
  • 1,381
  • 5
  • 21
  • 31
0
votes
1 answer

LINQ with JOIN Operations

i would like to have a LINQ statementlike this in Simple words i have two tables A and B. A contains fields id,name,amt1,userid. Table B contains id,userid,amt2. I wanted the details of table A in which A.userid=B.userid but B.id!=A.id Can any one…
-1
votes
0 answers

Convert SQL Query with join multipe tables to LINQ to Entities

I have this SQL query build a view in SQL. This is with the relationship with multiple tables and UnionAll another Sequence of relationship. SELECT dbo.StudentAttendance.StudentID, dbo.StudentAttendance.StudentName,…
-1
votes
2 answers

LINQ Count() with Case When

I have a SQL Server query and I rewrite this query in c# by using LINQ. In the T-SQL query, there is a sum like that: SELECT Date, Name, SUM(1)*(CASE WHEN Name='Sam' && Date=GETDATE() THEN 0.5 ELSE 1 END) AS ItemCount, …
simoncare
  • 75
  • 5
-1
votes
4 answers

How can i use Count with condition in LINQ

I wanted to get the number of times that , the customer participant our events. So the sql code is suppose to be like this. SELECT COUNT(CustomerID) FROM EventsParticipants WHERE (CustomerID == Session["CustomerID"]); And LINQ code is like this is…
FENR1R Ace
  • 68
  • 8
-1
votes
1 answer

SQL query to LINQ INNER JOIN

I need to translate SQL query to LINQ and have no idea how. I have two tables: Bins and DataFromBins. DataFromBins contains column BinId which refers to Bins.Id What my query does is selecting most recent row for each BinId from DataFromBins and…
-1
votes
1 answer

Calculate row number over group in linq and take only those with row number 1?

What would be the LINQ counterpart to get the row number over partition and then get only those records having row number as 1? Here is the SQL which I want to convert to its LINQ implementation: select ROW_NUMBER () OVER (PARTITION BY TASKKEY …
-1
votes
2 answers

Converting SQL subquery to LINQ

I am new to LINQ and trying to convert an SQL subquery to lINQ. Can we write subqueries like SQL in LINQ? here is the database Table EMP Name …
-1
votes
1 answer

Cannot convert implicity type Syste.Linq.IQueryable<> to

I have this SQL query: SELECT project_id,count(project_id) as vote_count from Votes group by project_id; Write it in LINQ syntax: public int GetCountOfVotes() { using (var db = new SafetyFundDbContext(Options)) { var result =…
-1
votes
2 answers

Convert this SQL with left join to LINQ

There are two tables, school and term. The school record must be shown, but the term record may not yet exist, therefore, the term may be null (thus the left join). The left joined table must be filtered by date for the current term if it exists.…
Mike G
  • 396
  • 1
  • 4
  • 16
-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" + "'…
-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
-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
  • 201
  • 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
  • 414
  • 2
  • 9
  • 26
-2
votes
1 answer

I need help to Convert a SQL Statement to C# LINQ

I need help with Converting this Select statement in LINQ C# Code SELECT TagName from Tags Where TagId IN( SELECT TagId from PresentationTags Where PresentationId = 2 )
ChR1sMC
  • 31
  • 1
  • 7
1 2 3
14
15