Skip to main content

All Questions

0 votes
1 answer
33 views

How can I inline parameters in EFCore?

Then track performance of query you can invoke ToQueryString method. If you have a lot of parameters in query it just add @p1, @p2, etc. What to do if you want inline it?
CMaker's user avatar
  • 664
0 votes
1 answer
71 views

String interpolation inside a formattable string in C#

I am in the process of replacing Dapper with EF Core in a project. Specifically using the new Database.SqlQuery and Database.ExecuteSql functionality with EF Core. I like how they use ...
Samuel Wahlberg's user avatar
1 vote
1 answer
96 views

How to properly manage and dispose SqlConnection with SqlCredential in EF Core using Dependency Injection?

I am working on an ASP.NET Core project where I am using SqlCredential for database authentication, provided by a SqlCredentialProvider which is designed as a singleton to ensure a single instance ...
Hao Li's user avatar
  • 26
-5 votes
0 answers
80 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); ...
JeeShen Lee's user avatar
  • 3,646
0 votes
0 answers
34 views

Entity Framework Core not recognising mapped user-defined function

I'm using Entity Framework Core with .NET 8 and trying to call a user-defined function from C# code. I'm following the instructions here but have a slightly different use case. Rather than having the ...
amarsha4's user avatar
  • 483
1 vote
2 answers
31 views

How do I ensure sequential document numbering using EF Core with a SQL database?

I have a simple application that must assign a sequential number without gaps or duplicates to each Document that is created i.e. 1, 2, 3 etc. A different document type will have a different numering ...
Jimbo's user avatar
  • 22.8k
0 votes
0 answers
41 views

Overriding identity tables properties / columns in EF Core 8 has no effect

I'm overriding the IdentityRole / IdentityClaim, etc. However, I've noticed that some of these fields has no effect either in Fluent API or via attributes. Class that overrides IdentityRole<Guid>...
Deukalion's user avatar
  • 2,626
0 votes
0 answers
42 views

Trouble Determining Dependent Side in One-to-One Relationship with Entity Framework Core

I'm currently working on a project using Entity Framework Core in a .NET Core application. I'm having trouble determining the dependent side in a one-to-one relationship between the User and Account ...
changedevelopersoftware's user avatar
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 ...
Max's user avatar
  • 93
1 vote
1 answer
59 views

Using FromSql or FromSqlInterpolated

According to this documentation (https://www.learnentityframeworkcore.com/raw-sql/from-sql) you should do this: string value = "value"; _dbContext.Set<T>().FromSqlInterpolated($"...
user7849697's user avatar
0 votes
2 answers
82 views

Bulk Insert not respecting Id column with Linq2Db and Entity Framework Core

I am using LINQ to DB with the linq2db.EntityFrameworkCore for bulk-entering of some records. With EF, I just save the records with a 0 in the Id property and they use the sequence I set up on the ...
Killnine's user avatar
  • 5,790
0 votes
0 answers
83 views

Why is this PostgreSQL query with LIMIT so slow?

I have a .NET WebApi with two entities (please forgive the silly names, it's just an example): public class Father { public int Id { get; set; } public string Name { get; set; } = null!; ...
Alessandro's user avatar
  • 3,743
0 votes
1 answer
121 views

Sending parameters to EF Core SqlQuery

Is sending parameters like this with SqlQuery safe against SQL injection? var page_param = new SqlParameter("page_param", page); var pageSize_param = new SqlParameter("pageSize_param&...
Gurhan's user avatar
  • 1
1 vote
0 answers
65 views

Table Design for Calculating Median Over User-Defined Period from Pre-Processed Data

I’m working with a table that contains pre-processed data from several other tables. This data is segmented by a time period (like a day) to speed up queries that could take minutes if I had to ...
Gustavo's user avatar
  • 21
0 votes
0 answers
42 views

Issue while saving using Entity Framework Core with datetime columns constraint

(this is another side, something similar but the others are difference to this question which was answered Issue while saving using Entity Framework Core with constraint) I have a table UserSession ...
Ming Hieu's user avatar
  • 181

15 30 50 per page
1
2 3 4 5
42