zzz projects Dapper Tutorial
Getting Started Documentation 3rd Party Libraries Knowledge Base Online Examples
  • Getting Started
  • Documentation
  • 3rd Party Libraries
  • Knowledge Base
  • Online Examples
  •   Download  

Dapper Tutorial - Knowledge Base (KB)

21 results in tag: sql-server

How can I use Dapper to insert and retrieve the identity value?

How do I perform an insert to database and return inserted identity with Dapper?...I've tried something like this:...string sql = "DECLARE @ID int; " + "INSERT INTO [MyTable] ([Stuff]) VALUES (@Stuff); " + "SELECT @ID = SCOPE_IDE...
c# dapper sql-server
asked by ppiotrowicz

Why with parameters, the stored procedure executesql is slow in Dapper?

I'm using dapper-dot-net as an ORM and it produces the following, slow-executing (1700ms), SQL code. ...exec sp_executesql N'SELECT TOP 5 SensorValue FROM "Values" WHERE DeviceId IN (@id1,@id2) AND SensorId = @sensor AND SensorValue != -32768 AND SensorVa...
dapper sql-server
asked by m__

How to use Dapper to put a C# List into a database

Using ...dapper..., how can I insert a ...C# List... to database. Previously without ...dapper... I used the below code to ...insert the List values to database.......try { connection.Open(); for (int i = 0; i < processList.Count...
c# dapper sql-server
asked by Praveen

How to execute in Dapper a stored procedure with user-defined table type (UDT) parameter?

I have a stored procedure ...InsertCars... which accepts list of user defined table type ...CarType.......CREATE TYPE dbo.CarType AS TABLE ( CARID int null, CARNAME varchar(800) not null, ); CREATE PROCEDURE dbo.InsertCars @Cars AS CarType RE...
c# dapper sql-server stored-procedures
asked by imodin

How can I use Dapper and send a string to SQLServer as NULL?

I've got a scenario where a string in C# can be ...null.... I need it to be ...NULL... on SQLServer....I'm sending it to SQLServer using Dapper with a query like:...connection.Query<MyObject>("[dbo].[sp_MyStoredProcedure]"), new { StartDate: startDate...
c# dapper sql-server
asked by crush

What best practices to use for connection and query in Dapper?

So i've read a bunch of links/SO questions, but i still can't get a clear answer on this....When performing SQL queries with Dapper in an ASP.NET application, what is the best practice for opening/closing connections?...Here's the pattern i'm currently fo...
.net asp.net c# dapper sql-server
asked by RPM1984

In Dapper, how can I update several entries in one sql statement?

I am attempting to use one single Update statement to update multiple records with different values (I'm not trying to update many rows to have the same values which is pretty straight forward). Here's what I'm trying right now:... using (var cn = Get...
c# dapper sql-server
asked by Kento

How to pass Table Valued Parameters with Dapper Dynamic Parameters?

I was trying to create a generic method, which can read the parameters name and value from a class at Runtime and create parameter collection for Dapper query execution. Realized that till the point all parameters are Input type it works well, but if I ha...
c# dapper datatable sql-server stored-procedures
asked by Mrinal Kamboj

Using Dapper, how to map a string column to a generic list?

I have the following model:...public class Model { public string Name { get; set; } public List<int> Numbers { get; set; } } ...And an ...SQL... query that returns the following dataset containing two nvarchar columns:... Name | Numbers 'foo' | '1,...
dapper dapper-extensions sql-server string-split
asked by Mugen

How to use QueryMultiple method to allows you to get a result and a count at the same time in Dapper?

I wrote two segments of SQL command and want to process in one query like this:...SELECT COUNT(*) FROM books SELECT * FROM books ORDER BY bookID OFFSET 1000 ROWS FETCH NEXT 10 ROWS ONLY ...How can I use ...conn.QueryMultiple... method to get ...count... ...
.net c# dapper sql sql-server
asked by ineztia

In Dapper, how can I send more than 2100 parameters with an IN clause?

I have a List containing ids that I want to insert into a temp table using Dapper in order to avoid the SQL limit on parameters in the 'IN' clause....So currently my code looks like this:...public IList<int> LoadAnimalTypeIdsFromAnimalIds(IList<int> anima...
c# dapper sql-server
asked by Chris B

When the PK column is not an identity column, how do I insert data with Dapper?

I'm trying to insert data using Dapper.Contrib, in a table where the primary key column is not an identity column....The database table is created with this script:...begin transaction create table dbo.Foos ( Id int not null, Name...
c# dapper dapper-contrib sql-server
asked by user247702

Using Dapper, how to map a stored procedure to a table-valued parameter?

In my project we are using Dapper to connect with database for operations....I have created a stored procedure in my SQL Server database as:...CREATE PROCEDURE dbo.usp_Check @TestTableType [dbo].[TestTableType] READONLY AS BEGIN SELECT TestTa...
c# dapper sql-server stored-procedures table-valued-parameters
asked by Rahul

Is Dapper the quickest method to convert a SqlDataReader result to an object?

I'm comparing materialize time between Dapper and ADO.NET and Dapper. ...Ultimately, Dapper tend to faster than ADO.NET, though the first time a given fetch query was executed is slower than ADO.NET.... a few result show that Dapper a little bit faster t...
ado.net c# dapper sql-server
asked by witoong623

How to return a list of data to Dapper by executing a stored procedure?

I am trying to return data using Dapper via stored proc...My DTO Class is similar to below (removed some properties for brevity)...public class CarDTO { public int CarID { get; set; } public string Manufacturer { get; set; } public List<CarOpt...
.net c# dapper sql sql-server
asked by Ctrl_Alt_Defeat

How with Dapper to get the returned value of a stored procedure?

I have a stored procedure of this form:...CREATE PROCEDURE AddProduct (@ProductID varchar(10), @Name nvarchar(150) ) AS SET NOCOUNT ON; IF EXISTS (SELECT TOP 1 ProductID FROM Products WHERE ProductID = @ProductID) ...
dapper sql-server tsql
asked by Matt W

In Dapper, why I get the error "The connection does not support MultipleActiveResultSets" with async / await?

I have the following code using Dapper.SimpleCRUD :...var test = new FallEnvironmentalCondition[] { new FallEnvironmentalCondition {Id=40,FallId=3,EnvironmentalConditionId=1}, new FallEnvironmentalCondition {Id=41,FallId=3,EnvironmentalConditionId...
async-await c# dapper foreach sql-server
asked by MotKohn

How to get output from a stored procedure when using Dapper?

I just started learning Dapper in C# but I am having difficulty in executing stored procedures with two or more SQL Statements in one transaction....How do you get the output parameter of a Stored Procedure that contains both Insert and Select statement...
c# dapper sql sql-server
asked by thecodeexplorer

In Dapper, how to get the SQL Exception number when an error occurs?

My stored procedure is throwing custom errors to handle validation within a multi user web app. This is working as expected in SQL Server with error number 50001 being returned however when my C# code catches the error it always has the error number 50000...
c# dapper sql-server
asked by OjM

Why I get an error in Dapper with column string parsing?

I have the following table...create table tblWorkers ( Id int identity, WorkerId nvarchar(8), Username NVARCHAR(50) not null, Password NVARCHAR(12) not null, Token NVARCHAR(max) null, CONSTRAINT PK_WorkerId PRIMARY KEY (WorkerId) ...
.net c# dapper sql sql-server
asked by Techie

Page 1 of 2
  • 1
  • 2
  • ยป

Prime Library

Performance

  • Entity Framework Extensions
  • Entity Framework Classic
  • Bulk Operations
  • Dapper Plus

Expression Evaluator

  • C# Eval Expression
  • SQL Eval Function
More Projects...
Get monthly updates by subscribing to our newsletter!
SUBSCRIBE!