dapper

记一次ORM的权衡和取舍

蹲街弑〆低调 提交于 2019-12-18 04:16:05
面对ORM的选型,有些人是根据自己熟悉程度来评判,有些人是根据他人的推荐来抉择,有些人觉得都差不多,随便了。当自己要真正做选择的时候,以上的这些依据都无法真正说服自己,因为不同的业务需求,不同的团队构成都会造成选型的差异,而且特别大,这里谈一谈自己的选型。 1.1需求背景介绍 我所在的公司是做互联网产品,对性能有着 极致的要求 ; 后台人数也不算多,尽量人尽其用,技术水平呈 梯度分布 ; 因为产品需要长期维护,所以对 代码质量 要求非常高,必须做 评审和单元测试 ; 对技术的 可维护 性,可扩展性要求很高,因为资源有限; 因为资源有限,所以在 生产力和性能 之间需要做一个 平衡 ; 1.2需求分析 难点   我们知道没有完美的技术,鱼和熊掌无法兼得,所以我们必须择优录取,这里的复杂度在于你要对所选择的技术优缺点有一个 360度的环评 ,最好能展示各自 优缺点对比 一览图,最后依据数据来证明你的选择对的,是对团队和业务负责的。 现状   不知道你有没有呆过这样的团队: 选什么技术从不讨论,大伙各自闷声干,等干出来你才知道原来对方是用的IBatis.NET。 你是后面入职的,你只能在前人的基础上做维护,尽管你觉得这个技术不是最优的,但是你也无法了解当初为什么做这样的选择。 在入职后,没有规范的技术培训和规范,你一边Google一边编码一边骂娘。  

.net core 2.0+superui +Dapper.SimpleCRUD+mysql+NLog

╄→尐↘猪︶ㄣ 提交于 2019-12-18 03:26:08
**_ .net core 2.0+superui +Dapper.SimpleCRUD+mysql+NLog _** 前端框架 superui http://www.supermgr.cn/ 1、组件丰富,扩展强大 大量优秀成熟开源组件,兼容性强,高扩展性。 2、炫酷华丽,风格多样 bootstrap风格UI,华丽而炫酷,组件风格和控制代码分离,风格千变万化! 3、各种浏览器,全面兼容 各种PC浏览器(IE9+、chrome、firefox、safari等)等浏览器,全面兼容,极致体验! 4、标准化、组件化 遵循html5+css3+js标准,兼容性好、扩展性强。 数据库orm 访问框架 Dapper.SimpleCRUD https://github.com/ericdc1/Dapper.SimpleCRUD simple CRUD helpers for Dapper 日志管理 NLog 进行文本日志管理 实用 符合国情的RBAC(基于角色的访问控制),可以直接应用到你的系统。 权限资源 菜单权限 经理和业务员登陆系统拥有的功能菜单是不一样的 按钮权限 经理能够审批,而业务员不可以 来源: https://www.cnblogs.com/lyl6796910/p/7575165.html

Dapper and anonymous Types

喜欢而已 提交于 2019-12-17 23:06:06
问题 Is it possible to use anonymous types with Dapper? I can see how you can use dynamic i.e. connection.Query<dynamic>(blah, blah, blah) is it then possible to do a .Select(p=> new { A, B ,C }) or some variation of that afterwards? Edit I thought I'd show you how I am using Dapper at the moment. I tend to cache (using an InMemoryCache) data so I just do one big query at the beginning (which is super quick using Dapper) then I use Linq to sort it all out in my Repository. using System; using

Multiple SQL statements in one roundtrip using Dapper.NET

杀马特。学长 韩版系。学妹 提交于 2019-12-17 23:04:47
问题 There is a nice feature in ADO.NET that allows you to send multiple SQL statements to database in one roundtrip and receive results for all statements: var command = new SqlCommand("SELECT count(*) FROM TableA; SELECT count(*) FROM TableB;", connection); using(var reader = command.ExecuteReader()) { reader.Read(); resultA = reader.GetInt32(0); reader.NextResult(); reader.Read(); resultB = reader.GetInt32(0); } Is there a similar feature in Dapper.NET? 回答1: Yes, the Dapper QueryMultiple

Problems connecting to local MySQL server

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 21:00:23
问题 I have problems connecting to a local MySQL database. I made sure the server is running and i can connect to the server using the user and password from the connection string and create databases with the terminal. I'm using visual studio community on a mac and MySQL 8.0.16. Example: Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace ReadSQL { class Program { static void Main(string[] args) { DataAccess dataAccess = new

Using Dapper with SQL Spatial Types as a parameter

偶尔善良 提交于 2019-12-17 18:30:02
问题 I've got a system which basically has to do a query like this: SELECT * FROM MyTable WHERE @parameter.STIntersects(MyGeometryColumn) This is quite simple to do when using vanilla SQL parameters, you just have to create your parameter in a non-typical way (where the builder variable is a SqlGeometryBuilder which I use to create a rectangle): command.Parameters.Add(new SqlParameter { UdtTypeName = "geometry", Value = builder.ConstructedGeometry, ParameterName = "@paremeter" }); Now, When I try

Simple inner join result with Dapper?

半腔热情 提交于 2019-12-17 17:54:29
问题 I can't seem to find documentation or examples for my problem (been searching a while now). I think my problem is pretty straightforward, so here goes. I have two tables. My primary table is called Persons and the secondary table is PersonEntries. For each person in Person table, i can have 0 or more entries in the PersonEntries table. Like this. Table: Person Id Name Table: PersonEntry PersonId CheckinTime CheckoutTime I have two objects like this public class Person { public string Name;

Get DateTime as UTC with Dapper

北战南征 提交于 2019-12-17 17:32:43
问题 I'm using Dapper to map my entities to SQL Server CE. If I save a DateTime with Kind=Utc , when I read it back I get a DateTime with Kind=Unspecified , which leads to all kind of problems. Example: var f = new Foo { Id = 42, ModificationDate = DateTime.UtcNow }; Console.WriteLine("{0} ({1})", f.ModificationDate, f.ModificationDate.Kind); connection.Execute("insert into Foo(Id, ModificationDate) values(@Id, @ModificationDate)", f); var f2 = connection.Query<Foo>("select * from Foo where Id =

Does Dapper support inserting multiple rows in a single query?

≡放荡痞女 提交于 2019-12-17 17:09:46
问题 Does StackExchange.Dapper support the following SQL syntax? INSERT INTO MyTable (a, b, c) VALUES (1, 2, 3), (4, 5, 6), (7, 8, 9); I've seen some examples where you can pass in a List to be inserted but the descriptions I've seen suggest it is just looping and doing multiple inserts. My research suggests doing a single query with multiple rows in it is faster so I'm curious to know if Dapper supports this with a list or not. 回答1: No it doesn't. Actually, bulk insert is one of the most

Dapper vs ADO.Net with reflection which is faster?

隐身守侯 提交于 2019-12-17 16:49:46
问题 I have studied about Dapper and ADO.NET and performed select tests on both and found that sometimes ADO.NET is faster than Dapper and sometimes is reversed. I understand this could be database issues as i am using SQL Server. As it is stated that reflection is slow and i am using reflection in ADO.NET. So can anyone tell me which approach is the fastest? Here what i coded. Using ADO.NET DashboardResponseModel dashResp = null; SqlConnection conn = new SqlConnection(connStr); try { SqlCommand