All Questions
3,772
questions
0
votes
0
answers
28
views
Use some kind of helper function In EF Select query to make subquery [duplicate]
I have several tables that handles different kinds of translations for my entities and those tables to linked via relations to other entities.
I use subquery to directly access translations tables ...
1
vote
2
answers
120
views
Multiple tables query with repository pattern
I have an ASP.NET Web API project, and have implemented repository and unitOfWork patterns.
I currently have a big SQL query that I want to implement in code, it includes a lot of tables and joins.
My ...
1
vote
1
answer
56
views
Join tables based on StartsWith function
I have two tables to join. The joining condition is a column that should be like or starts with the other column, not exactly equal. How to do that in Linq? This is my function:
public async Task<...
0
votes
2
answers
66
views
How do I do an inner GroupJoin on dotnet?
I'm using .NET 6 with Entity Framework. This is my situation:
I have a BenefitEntity (with Name and Description properties and a relationship with BenefitCategory) and this BenefitCategory which has ...
1
vote
1
answer
51
views
Group by, count distinct SQL query to IQueryable using Linq
I am trying to translate the following SQL into IQueryable, so I can access the result and filter on different conditions, before the data is retrieved from the database,
but I get an error that the ...
-1
votes
2
answers
112
views
Query (or LINQ in Entity Framework) for getting user's rank
I have a SQL Server database with a table named Users.
This table has 2 columns: XP (int32) and Name (nvarchar).
I need a SQL query or Linq (this is better because I'm using Entity Framework in C#) ...
0
votes
2
answers
97
views
What should we do If we have Or condition in INNER JOIN with EF Linq?
I the code below I have a TSql query which has Or condition in its join. If I want to convert it to Linq in C# how can I rewrite it.
SELECT P.Id AS ProductId
FROM generalinv....
1
vote
0
answers
142
views
Converting SQL ROW_NUMBER to Linq produces wrong translation
I have the following SQL code and I want to convert it to a LINQ query in Entity Framework Core 8.
SELECT *
FROM(
SELECT ROW_NUMBER() OVER (PARTITION BY StaffId,[Location] ORDER BY [Timestamp] ...
0
votes
1
answer
49
views
How to apply the condition after group by in linq C# SQL commands
I have a query and everything in my query works well without the last condition
(where s.Result == "Accepted" && s.TypeofRest == "Primary"
)
, I use the last condition to ...
0
votes
1
answer
96
views
Return multiple count from linq query
I have two arrays of strings with champion names in request. I want to calculate wins and loses for matches where one team contains champions from request.TeamChampionNames and other team contains ...
0
votes
1
answer
569
views
Is it possible to call a scalar function in entity framework?
I have a scalar function that takes 2 parameters and returns an integer.
In sql I can call the function by simply including it in my sql statement. IE
select funcname(dateparamfrom,
dateparamto) as ...
0
votes
1
answer
92
views
The LINQ expression could not be translated while using array of dates
I have the following LINQ code with me
List<DateTime?> selectedDates = new List<DateTime?>();
var sql = _dbContext.Seat
.Where(s => s.IsActive == true && s.FloorId == 1404)
...
1
vote
1
answer
100
views
How do I create a query using System.Data.Entity similar to a [SELECT * FROM "" WHERE "" ] SQL query?
For example I have the following query already which works fine:
public user Get(int id)
{
return userContext.users.Find(id);
}
However I would like a query which will return the object that ...
1
vote
2
answers
55
views
Is there a better way to get full row of calculated group by using LINQ
This question is a further question to https://stackoverflow.com/questions/157786/how-do-i-get-the-max-row-with-a-group-by-in-linq-query. Besides the max value and the group key, I need the every ...
1
vote
1
answer
76
views
How to merge two rows into one in linq query in c#
I have a sql table:
Id
SENDER
USERD_ID
BODY
TITLE
THREAD_ID
REPLIED
1
2
15
sth
some title
NULL
NULL
2
2
16
NULL
NULL
NULL
NULL
3
2
17
NULL
some title
NULL
NULL
4
1
15
sth1
question
501
1
5
3
15
...