Questions tagged [sql-to-linq-conversion]

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

243 questions
0
votes
1 answer

SQL query execution on WP7.1 SQL Server CE database

I need to develop a function that takes a SQL query as input and execute this in phone database (SQL Server CE) and return result. As far I know we can query SQL Server CE in wp7.1 only through LINQ. So is it possible to develop that kind of…
gmtek
  • 741
  • 3
  • 7
  • 25
0
votes
1 answer

Converting SQL to LINQ formatting where clause

Qry = "select childID,ChildEmail,ChildUserID, ChildPassword from ChildProfile "; Qry = Qry + " where ucase(ChildFName) = '" + Strings.UCase(Strings.Trim(Txtname.Text)) + "' and ucase(childlname) = '" +…
vini
  • 4,657
  • 24
  • 82
  • 170
0
votes
4 answers

Converting this SQL to LINQ

I have the following SQL statement to be converted into LINQ in C#. The @amount variable will be a C# variable. DECLARE @amount DECIMAL(20,2) SET @amount = 120.30 UPDATE INVOICES SET AmtPaid = AmtPaid + @amount WHERE InvoiceNum = 'AC0000034550'
user466663
  • 815
  • 4
  • 18
  • 40
0
votes
3 answers

Converting SQL to LINQ: The range variable conflicts with a previous declaration

I'm trying to convert this rather complex (from my perspective as I don't deal with SQL) query into LINQ: SELECT f.description, s.description, file_no,taskid, h.description from_userid, userid, …
Drakkainen
  • 1,142
  • 11
  • 25
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,447
  • 5
  • 23
  • 33
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
1 answer

how to write linq query with join on 3 tables performing sum and multiplication

How can i write a query in linq c#(EF Core 6) for total price and also map other fields of DTO along with total price. sql Query: SELECT (sum(c.ExtraPrice) + (a.PricePerSqM*10)) as TotalPrice FROM dbo.Cities a JOIN dbo.CityExtras b ON a.CityId =…
Hareem
  • 1
  • 3
-1
votes
1 answer

Sql statement to linq conversion

I want to get count of Testhistories using group by but through error when using linq. Without group by got the count but that was wrong. This mysql query is working fine SELECT t.RecordId AS `Id`, t.Name, (SELECT COUNT(*) FROM …
Technorg
  • 222
  • 1
  • 5
-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
  • 1
  • 8
-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
  • 9
-1
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
  • 33
  • 1
  • 7
-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
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 =…
Gintars Lazda
  • 91
  • 1
  • 8
-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
  • 406
  • 1
  • 6
  • 19