All Questions
33,062
questions
0
votes
0
answers
29
views
Binding data inside a DataGrid inside a DataGrid.RowDetailsTemplate / C# WPF
I'm learning C# and WPF for a personal project that I'll use for my job.
I'm trying to create a DataGrid inside another DataGrid. Specifically, I want my first SQL query to display some data, and when ...
0
votes
2
answers
62
views
Why do I need to model a join table class?
I have two classes in C#:
public class Student
{
public string Name {get; set;}
public string Email {get; set;}
public List<Course> Courses {get; set;}
}
public class Course
{
...
0
votes
0
answers
29
views
Error "To change the IDENTITY property of a column, the column needs to be dropped and recreated."
I'm a beginner and i am having this error when i use the update-data base, after the migration:
"To change the IDENTITY property of a column, the column needs to be dropped and recreated."
...
-3
votes
1
answer
80
views
I cannot modify the table in my database with C# [closed]
I created a database and a table in Microsoft SQL Server, and I want to do some experiments with it in C#. I successfully connected to my database and I can read the first row of the table, too. But ...
3
votes
1
answer
88
views
Join tables with condition that all row values are unique
I have tables Machine and Inventory. In table Machine I have last running inventory properties. In table Inventory, I have new inventory id and properties (Not yet run in machine).
I have to return a ...
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 ...
0
votes
1
answer
69
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 ...
0
votes
0
answers
33
views
How to map value objects in dapper
i have the following entity
using MedRaise.Domain.Enums;
namespace MedRaise.Domain.Entities;
public class Appointment : Entity
{
private Guid _clinicId;
private DateTime _date;
private ...
2
votes
0
answers
59
views
How to convert this SQL query to NHibernate IQueryable query?
I have to create a query similar to the one below to paginate a parent-child query:
SELECT v.ProductId, MAX(v.Price) AS Price
FROM Variant v
GROUP BY v.ProductId
ORDER BY Price ASC;
I am using C# ...
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 ...
0
votes
0
answers
44
views
How to pass a specific parameter to my dataset
I have DataTable as a result of executing a stored procedure. The stored procedure is returning a number of tables, therefore Tables[0], Tables[1], etc.
I'm trying to query the first table, Tables[0], ...
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<...
1
vote
1
answer
95
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 ...
0
votes
0
answers
25
views
Nhibernate get max items
I have a plan table which is having the following structure
id plan_id plan_number
1 1 1
2 1 2
3 1 3
4 2 1
5 2 2
for each plan I would like ...
0
votes
2
answers
95
views
Convert a string to base 64 using T-SQL
I'm having the issue while converting the string to base 64 for encoding using T-SQL. As I use chatgpt to search and some function like
SELECT BASE64_ENCODE (CAST ('hello world' AS varbinary))
SELECT ...
0
votes
1
answer
65
views
Error in Uploading an Image to a localhost SQL server using ASP.NET Core and C#
I want to send image itself to a SQL Server on localhost (send an image from my computer to localhost using ASP.NET Core web service written in C#).
I tried this in my client side:
OpenFileDialog opf =...
0
votes
1
answer
37
views
How to select where in dataGridView C#
I using microsoft visual studio, and i have box number in datagridview as follows
Box Number
4433002
4433006
4433011
I want do some sql query like "SELECT NOTE FROM TABLE WHERE BOX_NUMBER IN ...
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 ...
0
votes
1
answer
33
views
local sqlite locked after executing SQL query [duplicate]
i am trying to debug a very strange behavior of my application: the problem is that when the code reach the blob.UploadFileAsync i have an exception saying that the file in question is used by another ...
0
votes
2
answers
113
views
Why isn't searching on an indexed column faster than a string comparison?
I was asked for a demonstration of how searching on an indexed column is faster than searching for a string prefix, so I created a quick test but the results were surprising and I can't see why.
The ...
2
votes
1
answer
31
views
Syntax to call a parameterized function in Entity Framework with one of the parameter being INTERVAL
I have a call in Entity Framework like this:
// storageConfiguration and retentionPolicy are some models
string storageId = storageConfiguration.StorageId;
int retentionDays = retentionPolicy....
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>...
0
votes
0
answers
41
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 ...
0
votes
1
answer
36
views
SQL query SELECT MAX return value is 9 but the total rows is 10. When the ID reaches 10 it seems it doesn't count the ID 10 [closed]
I programmatically auto increment my supplier id using max when inserting the agents becasue my supplier table consist of distributors which are manually encoded id and agent is auto increment. My ...
1
vote
2
answers
94
views
Use @ literal in SQL command text
I want to change a password for a user in MySQL which requires @ symbol. However, C# SQL command uses that as a parameter holder and because of that the following command fails.
command.CommandText = $...
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
0
answers
61
views
Execute query to SQL (no compile errors)
I'm trying to clean and afterwards insert a table via OPC. (dont want to buy premium SQL server for agent). I get no compile errors... But when I trigger I get the following error: "Test_Sander&...
0
votes
0
answers
40
views
the DataGridViewComboBox is not filled in
I created a database and wrote functions that should take column names from tables and put them in DataGridViewComboBoxCells. However, after running the program, no errors came out, but all ...
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 ...
0
votes
0
answers
63
views
Order table by collection value
I'm using PostgreSQL with Dapper.
My situation that I have 2 tables, GamePlayCount and Game from 2 databases (difference connection string) .
First thing I select the most rating game like I have ...
0
votes
0
answers
55
views
Updating Database from DataSet with multiple tables
I have an application with an editor of multiple DataTables, that are stored in a DataSet which I load through a DataAdapter. My objective is to update the database with all the changes in all of the ...
0
votes
2
answers
44
views
Oracle parameterized query for explain plan in C#
I have an explain plan query and I need to call with parameters in my .Net application. When I try it as following it gives me ORA-1780 Error. I have many parameterized queries in my application but ...
0
votes
1
answer
75
views
How to ignore trailing whitespace? [duplicate]
Say a SQL table contains a column of char(10), and a record contains the value "ABC" in that column. Entity Framework will pass ABC ("ABC" with 7 trailing spaces) when asked ...
-2
votes
2
answers
101
views
Get particular value from string in SQL query
I am working with a stored procedure where I am getting a string with different characters I want to get a value at last index
[AV] Z_Prem_454-3000_XXXXX_800+ [InstalmentScheme 6]
above is the string ...
1
vote
2
answers
62
views
Read a SQL-DOUBLE column as raw
I have data defined as double saved in a PSQL-Database (Actian) and I'm using DbDataReader to read the values. I know I can use GetDouble to read the value, but I would like read the raw value into a ...
1
vote
1
answer
198
views
Converting System.String to System.Guid
I'm currently having a bit of a problem trying to convert a string with guid behaviour inside my database to convert to an actual Guid in my application. I have tried a lot of things, which currently ...
0
votes
1
answer
42
views
nullreferenceexception from ExecuteScalar()
I really don't know what to write here. I was just coding and this stuff happened.
connection.Open();
SqlCommand cmd = connection.CreateCommand();
cmd.CommandText = "select count(*) from ...
0
votes
1
answer
33
views
Transaction Log for database is full because update file about 100mb
I try to insert the data of a file about 100mb in size by splitting it into parts, each about 65,000 characters into the sql server. The first time I insert it and the next time I update that data. ...
1
vote
1
answer
70
views
PostgreSQL query returning different results in DbEaver and C# (Dapper/ADO.NET) despite same server connection
It's currently 1:15 AM on April 23rd, 2024. My timezone is GMT +7. I have a C# application and a DbEaver application both connecting to the same PostgreSQL server. I execute a very simple query as ...
-2
votes
1
answer
84
views
How do I convert this Knuth hash code in C# to the SQL equivalent?
Can anyone help me to convert the C# code below (Knuth hash) to the SQL equivalent?
/// <summary>
/// https://stackoverflow.com/a/9545731
/// </summary>
static string CalculateHash(string ...
1
vote
1
answer
242
views
Dapper how to pass object with list of objects into stored procedure
I have a problem with executing an existing stored procedure using Dapper. The stored procedure takes some parameters and list of user-defined type object. I mimicked the required parameters in C#, ...
0
votes
1
answer
66
views
Is there a way to enforce a specific JSON structure for JSON column?
I have a column in my table that will hold JSON objects. I currently have the column defined as MY_JSON_COLUMN NVARCHAR(MAX)
Is there a way to make sure the JSON adheres to a specific structure?
For ...
0
votes
2
answers
46
views
sql difficulties counting one column and getting the oldest id with the same content
I'm making a school project in mvc .net core, where people should be able to send in a request for help and it will show on a screen, my difficulties comes with the part that other people should be ...
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($"...
0
votes
0
answers
133
views
using ajax with asp.net core mvc .NET 8 in visual studio 2022
I have a view that shows information from a sql tabel that I inserted in to a local DataTable I want to create a button that filters what is shown with ajax
this is the loop where the information from ...
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 ...
-1
votes
1
answer
106
views
How to correctly pass nvarchar parameter to SQL Stored Procedure from .NET Application?
I would like to execute a SQL stored procedure (SP) with parameters. However, I am having difficulties passing nvarchar (string) parameter called "office" to the SP.
If I want to execute the ...
0
votes
0
answers
61
views
Retrieving OUTPUT values from a table variable using Dapper
I have a SQL Proc which uses a MERGE statement to INSERT when not matched and the OUTPUT values are stored in a table variable
INSERT
(
[Code],
[...
0
votes
0
answers
57
views
Convert C# DateTime.Ticks to Bigquery DateTime Format
I have a column in my Bigquery table that is filled by C# Ticks:
DateUtc = DateTime.UtcNow.Ticks;
This is something like: 638148714773184690
I want to convert it to Bigquery DateTime.
-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#) ...