2,957 questions
-1
votes
0
answers
33
views
Dapper Mapping not working as expected. Using myql, asp.net core web api [closed]
I am fetching ProductTransfer table together with related products. Although the total records = 1200, am only getting three records returned by my api.
Here is my models
public class ...
0
votes
1
answer
58
views
Dapper query with parameter not holding temp table in subsequent query [duplicate]
I have C# code that executes a Dapper Query, creates a temporary table, and uses a parameter to pass a value. In a subsequent query temp table is not available and will throw an error
Invalid object ...
Best practices
1
vote
3
replies
119
views
How to make C# code more readable and maintainable when using Dapper and raw SQL queries in C#?
When we are using Dapper, we should use raw SQL queries within our code, and if the query is complex with multiple joins and windowed query, it is very difficult to maintain such code.
Putting all ...
2
votes
1
answer
106
views
Dapper returning Nulls for KeyValuePair
We are trying to use Dapper to get a list of records from a SQL database with the following snippet of code:
var result = await conn.QueryAsync<KeyValuePair<string,string>>("Select ...
-1
votes
1
answer
77
views
Child/Navigation properties not populate values in dapper
I have GetClientDocumentRequestResponse response dto. In this I have GetDocumentRequestClientResponse DTO which property name is client and GetDocumentRequestClientResponse DTO which property name is ...
0
votes
0
answers
64
views
Call Oracle stored procedure that takes ODCIVARCHAR2LIST parameter from C# using Dapper and Oracle Managed Data Access Core [duplicate]
I'm trying to call an Oracle stored procedure from C# that takes SYS.ODCIVARCHAR2LIST (a table of VARCHAR2) as input parameters.
The procedure works correctly in SQL Developer, but from C# (using both ...
-1
votes
1
answer
69
views
Accessing a dynamic property value using a variable when using dapper [duplicate]
Currently I am using Dapper to bring back a dynamic object using the queryasync call.
The problem is because everything is database driven we have to pass in the property name as a variable. Is there ...
1
vote
1
answer
148
views
Chunk insert using Dapper of 5000 rows did not have any performance improvement over inserting row by row [duplicate]
I have an Azure Function built using .NET 8.0, which reads data from an Excel sheet and deletes all rows in Azure SQL Server, then adds around 67,000 new rows.
I was doing this insert one by one with ...
0
votes
1
answer
162
views
Azure Durable Function not running as expected at scheduled time, no exception, no logs
I have an Azure Durable Function that's scheduled to run every day at 18:00:00 UTC to generate a premium leads report. The function is triggered, but sometimes it doesn't complete or seems to silently ...
0
votes
1
answer
66
views
Dapper DynamicParameters.ParameterNames not iterating in foreach loop
My task is to log the raw SQL that dapper is going to be querying the DB with.
So what I have done is made use of the decorator pattern and created my own class that implements IDbConnection
More info ...
0
votes
2
answers
155
views
Why does the C# compiler choose Dapper's extension method for IDbConnection instead of the instance method on my own type?
I have a custom class LoggingDbConnection that implements IDbConnection. This LoggingDbConnection class has its own public instance method, for example, QueryAsync<T>(...), which includes custom ...
1
vote
2
answers
92
views
Dapper is not mapping 1-to-many entities correctly
I am fetching nested 1-to-many entities dynamically. Dapper is not mapping 1-to-many nested entities correctly. Within map function, objs has 2 items. objs[0] is the parent. Parent entity is good with ...
0
votes
1
answer
164
views
How to perform Dynamic SQL Query Generation in Dapper?
Question:
How can I dynamically generate SQL INSERT and UPDATE queries in a generic repository using Dapper? Currently, I'm hardcoding the property names in the SQL queries, but I want to make this ...
1
vote
0
answers
83
views
Nest Objects to be be nested one more level further in Dapper .NET API
I have completely working code, which returns the desired result.
var query = @$"SELECT
boats.*,
gallery.*,
textblock.*,
engine.*,
generator.*,
media.*
FROM {...
2
votes
0
answers
229
views
Enum mapping with Dapper and npgsql (from Postgres enum type)
I have a bunch of enums in my Postgres database, and for now I always parsed the enums manually from string to the effective value inside my .NET code (first map to string and then convert). While ...
0
votes
1
answer
297
views
How to Safely Parameterize Table Names in C# to prevent SQL Injection?
I'm using Dapper in my project and I want to pass table name as a dynamic parameter in the query.
This is my code:
var tableName = GetTableNameDynamically<TEntity>();
using (var builder = new ...
0
votes
1
answer
100
views
Composite type parameter in PostgreSql using Npgsql,
I'm working with Npgsql and and Dapper I have some tables in PostgreSql with a composite data type:
create type datetimeoffset as
(
"DateTimeUtc" timestamp without time zone,
"...
0
votes
1
answer
227
views
How to Mock QueryAsync<dynamic> using Moq.Dapper
We have a class below that finds records in the list of tables provided in the parameters, and then deletes them within a transaction.
public async Task<IEnumerable<DataTableRecordsResponse>&...
2
votes
0
answers
55
views
Connection exception in asynchronous processing using Dapper, Channels, and BackgroundServices in .NET 6
I am working on an ASP.NET Core 6 Web API that uses Dapper and performs long-running processes dependent on balance checks to decide whether they can proceed or not. Previously, we identified an issue ...
-1
votes
1
answer
493
views
Aspire SQL Server connection issues
I've recently switched to using Aspire and I'm noticing some strange behaviors.
I'm getting the following error when trying to access the database:
System.InvalidOperationException: ...
2
votes
1
answer
91
views
Parameter for a column that contains a dash in its name
I am using Dapper with SQLite.
I have a table that is defined like so:
CREATE TABLE Example (
id INTEGER NOT NULL,
"some-field" TEXT
);
I wrote a console application in ...
0
votes
1
answer
132
views
CREATE a stored procedure using plain query text via NpgsqlConnection::ExecuteAsync
I am trying to create a stpored procedure via Npsql from C#
private async Task TestExecute(string cmdQuery)
{
var cnnString = $"Server=localhost;User Id=admin;Password=somepass;...
0
votes
2
answers
178
views
Using Dapper one-to-many (spliton) with generics
I am trying to map objects in a one to many relationship using Dapper. Assume a database with a Departments and a People table. People table has a DepartmentId column to create the relationship ...
-1
votes
2
answers
155
views
PostgreSQL stored procedure fails with dynamic parameters for date in Dapper
I'm using PostgreSQL with a .NET project, and I'm facing an issue executing a stored procedure through Dapper when using dynamic parameters to pass a DATE parameter.
The stored procedure is defined as ...
-2
votes
2
answers
203
views
Get List<string> or Dictionary using Dapper [closed]
SQLite query is
SELECT * FROM tblProducts WHERE Id = 1
How to get List<string> of all values or Dictionary with property and value, with Dapper;
1
vote
1
answer
166
views
Dapper - Unable to resolve property
I am trying to create a create method which will insert rows into my database.
Table
This is my database table. As you can see it has an accountId column
CREATE TABLE [dbo].[Transactions](
[Id] [...
0
votes
1
answer
231
views
Dapper logging when using connection from EF Core DbContext
I have a legacy code that is using dapper's QueryAsync() on DbContext's dbconnection:
var connection = _context.GetConnection();
await connection.QueryAsync<Guid>(query, parameters);
How do I ...
0
votes
1
answer
212
views
How to mitigate "No columns were selected" exception from GridReader
I am getting this exception from Dapper.SqlMapper.GridReader when calling
var resultSet = await SqlConnection.QueryMultipleAsync(query, parameters, commandType: CommandType.StoredProcedure);
var ...
1
vote
1
answer
190
views
How to create generic method of Dapper QueryMultipleAsync?
I am trying to create a generic method to get multiple data sets using Dapper. I will specify the list of expected data types and the method will give me the list of objects of the specific data type.
...
0
votes
1
answer
82
views
How to use Dapper with derived types
I have about 20 classes that are derived from ModelBase (which contains common things like CreationDate, Id etc).
Using Dapper, it is easy to save and delete these derived classes (all the work is ...
0
votes
1
answer
103
views
How to Insert a multi-nested item using C#/Dapper?
I have a series of classes that look like this:
public class SignUpList {
public int? SignUpListId { get; set; }
public IEnumerable<SignUpItem> Items { get; set; }
}
public class ...
1
vote
1
answer
806
views
What is the best way for dapper to map column name which is different from the class property name
To simplify the case, let's say I have the following table definitions in Oracle:
create table customer
(
id number(10),
name nvarchar2(1024),
primary key (id)
);
create table ...
0
votes
1
answer
139
views
Unable to perform BulkInsert of records into snowflake tables
public async Task<int> BulkInsertAsync<T>(string tableName, IEnumerable<T> data, int batchSize = 1000)
{
int totalRowsAffected = 0;
var batches = data.Batch(batchSize);
...
2
votes
0
answers
92
views
How to handle dynamic model mapping in Dapper QueryAsync based on multiple flags without ever-increasing if-else blocks
I am working on a Dapper query that fetches data for GraphQL query from multiple related tables like ImportJob, ImportJobChargeDetail, and ImportJobContainerDetail. The data that needs to be retrieved ...
2
votes
0
answers
204
views
.NET Dapper SqlMapper slow query execution
In .NET 8 with Npgsql and Dapper, our query is incredibly slow compared to executing it directly through another database manager.
In our code, we execute queries as such:
var query = "select ...
0
votes
1
answer
141
views
How to mock Query method in Dapper C# for unit tests?
My method in C# looks like this:
public bool Execute(IDynamicDatabaseConnection dbConn, List<DynamicGrid> loadObjects, out List<DynamicGridValue> result)
{
result = new List<...
0
votes
0
answers
133
views
Issue with Dapper : random connection timeout expired
I have the following issue in an ASP.NET Core app. With Dapper I connect to a SQL Server database and I randomly have this issue:
MoveNext : SqlException Message : Connection Timeout Expired. The ...
0
votes
1
answer
247
views
How to avoid timeout error in Dapper data access
I am working on an ASP.NET Core 6 project. I am using Dapper for my data access. When I used the data access on a long-running stored procedure, I got a timeout error.
This stored procedure usually ...
0
votes
0
answers
75
views
A proper way Dapper custom mapping settings initialization in ASP.NET
I have three-layers architecture mini-program as my hometask of some paid private online courses. Recently I added ASP.NET Core as replacement for my console presentation-lavel. But I also have custom ...
0
votes
1
answer
71
views
Insert parameters when sending notify event
I want to send some data to PostgreSQL using a NOTIFY event and I have the following code to do so
await using var conn = new NpgsqlConnection(connectionString);
await conn.OpenAsync();
await conn....
1
vote
1
answer
122
views
Implicit conversion from data type datetime to int is not allowed error in Blazor Server Application
I am building a Blazor app using Dapper.
I have a stored procedure with the following code, which executes perfectly when I test it in SSMS:
ALTER PROCEDURE [dbo].[...
1
vote
1
answer
536
views
Registration IDbConnection to use Dapper ORM in DI container as Scoped or Transient
Dapper use IDbConnection. I know the difference between Scoped and Transient but I wonder why some people register IDbConnection in DI container in Program.cs as Scoped and others as Transient. Is ...
0
votes
0
answers
77
views
Is there a limit for an Update with Output SQL Statement
I want to update records on a view and get back the updated records to process them in my application, the code is working fine for almost cases, but for a specific senario when I have more than 22000 ...
1
vote
1
answer
231
views
Dapper QueryAsync not returning some SQL rows when using UNION ALL
I'm converting a Visual Basic API to .NET 8 using the same SQL Server query with the same parameters, and I noticed that some rows are not being displayed in the response object.
The query uses UNION ...
0
votes
1
answer
69
views
column saving and serving without touching the column
I wrote an ASP.NET Core 8.0 Web API for an Angular frontend web site with node express and Postgresql 2 years ago we had a habit from that project with frontend programmers and my Web API. I give some ...
0
votes
0
answers
106
views
Dapper list values NULL, despite values present in stored procedure, visualizer return [duplicate]
I'm struggling w/some Dapper code. I have a singular, all encompassing list that I'm using in a couple different calls (handled by my stored procedure). This works well in most cases, but I'm ...
-2
votes
2
answers
784
views
Error when try to map entities in Dapper(Multi-map error: splitOn column)
Error:
System.ArgumentException: Multi-map error: splitOn column 'Id' was not found - please ensure your splitOn parameter is set and in the correct order (Parameter 'splitOn').
It happens when i use ...
0
votes
0
answers
60
views
How to get selected cell value of multi DataGridView in TabControl to main datagridview in form1 with VB.NET
I'm trying to get selected cell value of multi DataGridView in TabControl to main datagridview in form1 with VB.NET
Please Guide me
for example when I selected row in the Criteria1 tabcontrol with ...
0
votes
2
answers
128
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
1
answer
46
views
How to instantiate null object and property in C# with Dapper via SplitOn?
I have this stored procedure in the database:
SELECT
Cars.CarId AS carCarId,
Cars.VinCode AS carVinCode,
-- Cars.CustomerId AS carCustomerId,
Cars.NumberPlate AS carNumberPlate,
...