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...
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...
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...
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...
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...
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...
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...
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...
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,...
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... ...
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...
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...
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...
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...
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...
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)
...
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...
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...
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...
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)
...