micro-orm

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

Dapper: is it possible to customize the type mapping of a specific field of a specific type?

落花浮王杯 提交于 2019-12-21 20:22:30
问题 Let's say I have this User class: public class User { public int ID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string Email { get; set; } public DateTime DateCreated { get; set; } public DateTime LastLogin { get; set; } } Which I want to map to the following table: CREATE TABLE "user" ( "ID" int(11) NOT NULL AUTO_INCREMENT, "FirstName" varchar(45) DEFAULT NULL, "LastName" varchar(45) DEFAULT NULL, "Email" varchar(255) NOT NULL, "DateCreated

Why does Azure Database perform better with transactions

只愿长相守 提交于 2019-12-21 09:37:38
问题 We decided to use a micro-orm against an Azure Database. As our business only needs "inserts" and "selects", we decided to suppress all code-managed SqlTransaction (no concurrency issues on data). Then, we noticed that our instance of Azure Database responded very slowly. The " rpc completed " event occured in delays that are hundreds times the time needed to run a simple sql statement. Next, we benchmarked our code with EF6 and we saw that the server responded very quickly. As EF6 implements

Why does Azure Database perform better with transactions

谁说胖子不能爱 提交于 2019-12-21 09:36:04
问题 We decided to use a micro-orm against an Azure Database. As our business only needs "inserts" and "selects", we decided to suppress all code-managed SqlTransaction (no concurrency issues on data). Then, we noticed that our instance of Azure Database responded very slowly. The " rpc completed " event occured in delays that are hundreds times the time needed to run a simple sql statement. Next, we benchmarked our code with EF6 and we saw that the server responded very quickly. As EF6 implements

Get data using inner join from Dapper

妖精的绣舞 提交于 2019-12-12 20:03:32
问题 I am working on DB operations on one project and developing WinForms App C# and I am using Dapper to get data out of DB, I am stuck at situation where I need to retrieve data using inner join. Eg. I've two tables Authors and Book as Follow : public class Authors { public int AuthorId { get; set; } public string AuthorName { get; set; } } public class Book { public int BookId { get; set; } public string AuthorId { get; set; } public string Title { get; set; } public string Description { get;

PetaPoco - Multiple result set support

冷暖自知 提交于 2019-12-12 09:37:58
问题 My work recently starting using PetaPoco and although fantastic I missed the feature from Dapper which allowed multiple result grids from a single query to be processed into pocos. As a result I wrote my own implementation for PetaPoco - shown below - but has anyone written their own and care to share it? I thought there might be others out there who have missed this feature. 回答1: Edit (2016-06-27): As of version 5.1.181 of PetaPoco (currently a beta at the time of writing) this feature is

Unable to run update statement using Dapper (parameters error)

大兔子大兔子 提交于 2019-12-11 23:22:58
问题 I am trying to update a row using Dapper but I am having error on specifying parameters in my update statement An exception of type 'System.InvalidOperationException' occurred in IBM.Data.DB2.iSeries.dll but was not handled in user code Additional information: Not enough parameters specified. The command requires 3 parameter(s), but only 0 parameter(s) exist in the parameter collection. Repository.cs public void Update(Movie movie) { var sql = "UPDATE myDB.movies set title=?, genre=? where Id

Query spatial data with dapper

丶灬走出姿态 提交于 2019-12-10 06:58:04
问题 I've found some related questions, but the author gave up and went ahead with using stored procedures to do the 'mapping'. This is actually a continuation question from here Model public class Store { public int Id { get; private set; } public string Name { get; set; } public string Address { get; set; } public DbGeography Location { get; set; } } Querying using (SqlConnection conn = SqlHelper.GetOpenConnection()) { const string sql = "Select * from Stores"; return conn.Query<Store>(sql, new

Querying into a complex object with Dapper

大兔子大兔子 提交于 2019-12-08 17:20:53
问题 I have a Customer class with the following properties: public int Id { get; set; } public string Name { get; set; } public int AddressId { get; set; } public Address Address { get; set; } My goal is to write a Dapper query that will use an Inner Join to populate the entire Address property within each Customer that is returned. Here is what I have and it is working but I am wondering if this is the cleanest/simplest way to do it: StringBuilder sql = new StringBuilder(); using (var conn =

Why does the “Limit()” method no longer exist in the ServiceStack OrmLite v4?

浪子不回头ぞ 提交于 2019-12-08 12:06:55
问题 in ServiceStack OrmLite v3 you could do: var rows = db.Select<Employee>().Limit(10)); Or: var rows = db.Select<Employee>().Limit(5, 10)); // skips 5 then takes 10 However I cannot find these methods any longer in v4. I suppose I can do the following instead: var rows = db.SelectLazy<Employee>().Take(10); However how can I do a db.Select (not having to write direct SQL) which will translate to (in SQLite for example): SELECT * FROM Employee LIMIT 10; Also, is it possible to write an equivalent