All Questions
Tagged with linq sql-server
3,067
questions
0
votes
0
answers
17
views
Improving performance of contains method in ASP.NET MVC web application with large dataset
I have an ASP.NET MVC web application using C#, Visual Studio, and SQL Server. This is my code:
if (!string.IsNullOrEmpty(Name))
{
query = query.Where(x => x.PatientName.Contains(Name));
}
The ...
0
votes
0
answers
59
views
How do I set SQL Provider in C# Linq
I changed the default collation of my SQL Server 2022 database (and all string objects that already existed) to Latin1_General_100_CI_AS_SC_UTF8.
Unfortunately, Linq seems unable to handle this ...
-5
votes
0
answers
79
views
EF Core comparing DateTime performance. SQL CONVERT(Date) vs SQL DATEPART
I have a DateTime column called TimeStamp in my database table. It is indexed.
Which of the queries below gives me a better performance? QueryA or QueryB?
var dateOnly = new DateOnly(2024, 01, 01);
...
1
vote
1
answer
121
views
How to eliminate nested joins in generated SQL query?
I created a LINQ query in a .NET Core Application to retrieve some data. When checking the generated SQL for the LINQ I noticed nested queries in it. I want to optimize my LINQ query by removing the ...
0
votes
1
answer
85
views
Generic expression to find partial string matches against dynamic list of fields in LINQ query
As I understand it, in particular with SQL Server:
LINQ queries convert the query code into T-SQL to execute against the SQL Server.
LINQ code logic doesn't always seamlessly convert to T-SQL, which ...
0
votes
1
answer
73
views
How can I search for a DATE in Entity Framework
I'm trying to get a date from my database and I've tried different things, but nothing seems to work.
This is my date in the database 2024-04-18 19:47:36.337, it's defined as datetime in Microsoft SQL ...
1
vote
1
answer
53
views
System.InvalidOperationException: 'The ConnectionString property has not been initialized.' in ASP.NET Core 8, Entity Framework and Linq
I am using ASP.NET Core 8, Entity Framework and Linq to connect to a SQL Server database, but I am getting this error
System.InvalidOperationException: the ConnectionString property has not been ...
1
vote
1
answer
84
views
LINQ fails to translate an SqlFunctions method
I have a problem with my C# app. I am trying to fetch an item from the SQL Server database, in the database I can use the following query:
SELECT *
FROM [table]
WHERE [field] IS NOT NULL
AND [...
-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#) ...
1
vote
2
answers
110
views
SqlException for datetime column
I have the following LINQ query :
var studentRecords = context.Students
.Include(i => i.StudentsAdmission)
.Where(w => !w....
2
votes
0
answers
145
views
Query selects all columns even though only one column is selected
I have encountered an issue while working with Entity Framework Core 7 where the generated SQL query appears to select all columns from the table, even though I am selecting only one column in my LINQ ...
0
votes
2
answers
364
views
LINQ lambda optimization .NET 8
I have an EF Core repository function with lambda LINQ, used to read a home object with all of it's related objects:
public HomeObj ReadByIdWithObjects(int id)
{
var home = _context.Instance.Homes....
2
votes
1
answer
80
views
Use a range of integers to left join a table?
I have a hierarchy with two tables:
CREATE TABLE A (
Id nvarchar(50) NOT NULL,
ChildrenCount int NOT NULL
)
CREATE TABLE B (
ParentId nvarchar(50) NOT NULL,
I int NOT NULL,
...
0
votes
2
answers
164
views
Entity Framework Join with Group by select columns
I have 2 tables that I am trying to left join with a linq query
I want to left join 2 tables, i want to group multiple columns but I want to select specific columns and use datepart etc on some of the ...
0
votes
1
answer
56
views
Cannot perform SelectMany - Unable to materialize collection
query :
var nodes = (from n in _db.TreeNodes.Where(n => passwordCycles.Select(c => c.HorusId).Contains(n.HorusId))
from path in _db.TreeNodes.Where(p => (EF.Functions....