dapper

Dapper QueryMultiple Stored Procedures w/o mapping to Objects

主宰稳场 提交于 2019-12-23 22:36:37
问题 With dapper, I can do batch execute for Stored Procedures, something similar to: connection.Execute(@" exec sp1 @i = @one, @y = @two exec sp2 @i = @three", new { one = 1, two = 2, three = 3 }); However, the only means of retrieving data that I have seen till now is by using results.Read<Type>() What if the results don't map to an object? For instance, I am writing "generic" code to execute any SP with variable in/out parameters & result sets. Thanks 回答1: What API do you want? If you can

Dapper And System.Data.OleDb DbType.Date throwing 'OleDbException : Data type mismatch in criteria expression'

天大地大妈咪最大 提交于 2019-12-23 18:43:10
问题 Not sure if I should raise an issue regarding this, so thought I would ask if anybody knew a simple workaround for this first. I am getting an error when I try to use Dapper with OleDbConnection when used in combination with MS Access 2003 (Jet.4.0) (not my choice of database!) When running the test code below I get an exception 'OleDbException : Data type mismatch in criteria expression' var count = 0; using (var conn = new OleDbConnection(connString)) { conn.Open(); var qry = conn.Query

Specified Cast is not Invalid (Enum with int value, Dapper)

北城以北 提交于 2019-12-23 18:40:06
问题 I have a class with a (simple, first cut) implementation of user roles: class User { public Role Role { get; set; } // ... public User() { this.Role = Role.Normal; } public void Save() { Membership.CreateUser(...) } // System.Web.Security.Membership } enum Role : int { Invalid = 0, Normal = 1, SuperUser = 4096 } Before adding the role, everything worked fine (if that matters). Now, when I try to fetch users, this line fails: toReturn = conn.Query<User>("SELECT TOP 1 * FROM dbo.UserProfile

Kendo UI jQuery Grid Server Side Filtering

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 16:44:55
问题 I am using Kendo UI for jQuery Grid to display some data. So far I am using Client Side Filtering and Paging where all the data records were returned in the initial call to the server (Web API and Dapper are being used at server side). However, the idea of getting all the data in a single call from the server is no more feasible as the Datasource has grown with time. I have enabled the option for server-side paging and filtering using the following: serverPaging: true, serverSorting: true,

Dapper execute stored procedure raises ArgumentException about multi-mapping

核能气质少年 提交于 2019-12-23 15:09:16
问题 I have a stored procedure that I'm trying to execute using Dapper that is raising an error that doesn't appear to be pertinent to what I'm trying to do, although I can't seem to figure out what I'm doing wrong. Here is the signature of the stored procedure that I'm trying to call: ALTER PROCEDURE [dbo].[stp_UpdateInboundDaf] @InboundType varchar(255), @Id bigint, @UserId bigint, @DonationID bigint = NULL, @StatusId int = NULL, @FinalFlag bit = NULL, @ValidatedFlag bit = NULL, @SignedFlag bit

Difference between connection.OpenAsync and connection.Open when using Dapper QueryAsync method

余生长醉 提交于 2019-12-23 14:55:34
问题 What is the difference between using connection.OpenAsync() and connection.Open() when using dapper's QueryAsync method. Async: public async Task<IList<Product>> GetListAsync() { using (var connection = new SqlConnection(_connectionString)) { StringBuilder sql = new StringBuilder(); sql.AppendLine("SELECT Id, Name "); sql.AppendLine("FROM Product "); await connection.OpenAsync(); var tickets = await connection.QueryAsync<Ticket>(sql.ToString()); return tickets.ToList(); } } Not Async: public

Using Dapper with BLOBs and SQL Server CE

笑着哭i 提交于 2019-12-23 14:20:16
问题 When using BLOBs with more than 8000 bytes of data, you need to specifically set Parameter.SqlDbType = SqlDbType.Image to make it work (as explained here). Dapper, when it sees a byte[] field, defaults to a SqlDbType.Binary , which means for larger blobs, the inserts and updates will fail with a data truncation error. Is there an elegant solution to this problem? Only option I can see is to code the entire transaction with ADO.NET methods. 回答1: I had the same problem. Resolved as follows:

Why is dapper returning all zero's for Guid when doing a select but the guid value in table is set correctly?

六眼飞鱼酱① 提交于 2019-12-23 12:51:18
问题 I'm using dapper to query data from table and then cast it to an object. When it is cast to the object the guid property is set to all zero's, but all the other props are set correct. public class UserStuff { public int Id { get; set; } public Guid UId { get; set; } } public async Task<UserStuff> GetUserStuff(Guid uId){ using(IDbConnection conn = Connection){ string sQuery = "SELECT TOP 100 id, u_id " + "FROM TestTable WHERE u_id = @u_id "; conn.Open(); var result = await conn.QueryAsync

How to insert DbGeography to SQL Server using dapper

风流意气都作罢 提交于 2019-12-23 12:19:08
问题 I've created the model using System.Data.Entity.Spatial; public class Store { public int Id { get; private set; } public string Name { get; set; } public string Address { get; set; } public DbGeography Location { get; set; } } Inserting to DB using (SqlConnection conn = SqlHelper.GetOpenConnection()) { const string sql = "INSERT INTO Stores(Name, Address, Location) " + "VALUES (@Name, @Address, @Location)"; return conn.Execute(sql, store); } i get the exception type System.Data.Entity.Spatial

Azure SqlException: Database on server is not currently available

前提是你 提交于 2019-12-23 10:47:13
问题 Our site has been running for a few weeks in Azure without getting this error: SqlException: Database 'database' on server 'server' is not currently available. Please retry the connection later. If the problem persists, contact customer support, and provide them the session tracing ID of 'guid'. It finally got that one day when there were a little over 2K of active (concurrent) users. This is the closest question that I can find in SO. We are not using EF though but rather we're using Dapper.