Skip to main content

All Questions

Tagged with
3 votes
1 answer
240 views

MySql EFCore 9 Contains in array issue

I am trying to do a contains list linq sql query to a MySql database and the query cannot be translated to SQL. This same query works when using the SQLServer. var arr = new long[] { 5, 3, 2 }; var ...
Tyrone's user avatar
  • 63
-1 votes
1 answer
79 views

C# EF Core LINQ simple join

I am more used to manual sql query but I have to admit that EF core context & model is more convenient knowing I don't need to open and close database manually. All set upon new. But I really have ...
Vincent Krisna's user avatar
0 votes
0 answers
174 views

How do I perform an ExecuteUpdate on a MySQL DB Context DbSet<T>, given a List<T> of the current information?

I have three separate databases (Site A, Site B, Site C), using the same database software with some minor structural differences, from which the same types of data need retrieving, in some cases ...
SGBCLDS's user avatar
0 votes
1 answer
147 views

dbContext.SaveChanges() not updating single row as expected in .NET

I have 2 tables: TableA and TableB in MySQL on which I am trying to do some CRUD operations in .NET. I have written a function to insert a new row in TableA followed by updating a single row in TableB....
Krushnal Patel's user avatar
1 vote
1 answer
56 views

LINQ Query for below table

Table data: Id_Org_hierarchy Hierarchy_Name Parent_Id_Org_hierarchy 1 OGt 0 2 NHT 1 3 BATCH 1 2 3 Voice 1 I need result Like Below: Batch1(NHT,OGT) Details : Id_Org_hierarchy column value is present ...
Rani Thakur's user avatar
2 votes
1 answer
78 views

Left join to empty data using linq

I have the following query in MySQL. SELECT Pages.*, IFNULL(PagePermission.CanRead, 0) CanRead, IFNULL(PagePermission.CanWrite, 0) CanWrite, IFNULL(PagePermission.CanDelete, 0) CanDelete FROM (SELECT *...
Muntasir's user avatar
  • 808
1 vote
1 answer
127 views

How do I write a LINQ query for a list of users with their first article?

How do I write a LINQ query that would translate to the following SQL? SELECT u.id, u.username, a.id, MIN(a.created_at) AS firstArticle FROM users u INNER JOIN editorial_articles a ON a.user_id = u.id ...
glen-84's user avatar
  • 2,008
1 vote
1 answer
135 views

Multiple OR statements with LINQ

I'm trying to create a LINQ Statement for the following MYSQL Query: SELECT * FROM Movies WHERE movies.Actorid = 1 AND ( (Movies.Duration >= x1 AND Movies.Duration <= x2) OR (Movies....
M4SX5's user avatar
  • 195
0 votes
2 answers
78 views

How to use Exist sql function in Linq

var _query = _dbContext.CashVoucherDetails .Where(x => x.CreationDate.Date >= From.Date && x.CreationDate.Date <= To.Date && (x.Type == Common.TransactionType.CPV ...
Åfsħąl Ãtħąr's user avatar
0 votes
0 answers
75 views

EntityFramework query

CREATE TABLE IF NOT EXISTS users ( UserId int auto_increment, RegisterId int, PRIMARY KEY(UserId) ); CREATE TABLE IF NOT EXISTS products ( ProductId int auto_increment, ...
lowdegeneration's user avatar
0 votes
1 answer
1k views

Date and time between a date range in dotnet

I am facing the problem to know if DateTime is between a date range in the dotnet. For example if the x.SchedulerStart value is 2022-11-02 06:46:30 and x.SchedulerEnd value is 2022-11-02 23:26:30. I ...
Fatt Sky's user avatar
  • 680
-1 votes
1 answer
82 views

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`...
Technorg's user avatar
  • 240
0 votes
0 answers
218 views

How to cast a tinyint value from a MySql column to C# using Linq?

I'm trying to run the below query using Linq: var ResultRows = from MyRow in MyDataTable.AsEnumerable() where Convert.ToBoolean(MyRow.Field<byte>("IsTrue")) == ...
csharpnewbie's user avatar
0 votes
1 answer
227 views

Entity Framework Group BY causing Unable to cast object of type 'System.DBNull' to type 'System.String'

I am trying to run following EF query and return the exception on some instances of Databases //Contacts Stats summary Dictionary<ContactStatusEnum, int> contactStats = (await context.Contacts....
Sebastian's user avatar
  • 4,831
0 votes
1 answer
602 views

lambda expression function body to sql query

I would like to know if there is any way to do the next. I would like to extract compiled body of a function. class Program { public static void Main(string[] args) { int i = 5; ...
Mehdi Sh.'s user avatar

15 30 50 per page
1
2 3 4 5
36