dapper

Using Dapper to return XML string from T-SQL stored procedures

安稳与你 提交于 2019-12-01 06:15:24
问题 I am working on a project to convert a large VB6 application to .NET. I decided to create a project to provide a facade to the existing VB6 ADO code, where I am using the amazing Dapper extension methods to handle all the database code that the VB6 ADO functions used to do. One of the features I have to support in my new project is the ability to get the XML string results from T-SQL stored procedures (via the FOR XML). Dapper doesn't have support to return this XML that I can see. So, I

How to map an identity column, that has a different name, with Dapper?

孤者浪人 提交于 2019-12-01 05:13:25
I have a database with id columns like BookId, AuthorId, etc. My code files, however, just have an Id property. I'm attempting to convert parts of the program that use NHibernate with Dapper, so I'm trying to eliminate the need for both an Id and a BookId property on . NHibernate has a built in identity map that maps BookId to the Id property of Book objects and similarly AuthorId to the Id property on Author objects. Is there a way to do this Dapper, outside of giving an alias to the column, in the sql query? public class Book { public int Id { get; set; } public string Name { get; set; } }

How to use Dapper with MS SQL Server (2012) Geospatial / SQLGeography Column

此生再无相见时 提交于 2019-12-01 04:52:06
I have a SQL Server 2012 database with a table that contains a geography column and I want to use Dapper in a .Net application working with that database, but as far as I can tell and see in the Dapper code, "only" Entity Framework's DBGeography type is supported , the underlying SQLGeography data type has no other mentioning in the repository. Can Dapper handle these column types 'magically' nevertheless or would I have to explicitly write a Dapper.SqlMapper.TypeHandler for these? Support for SqlGeography has been added in the next release, again via the Dapper.EntityFramework package . I

Ignoring properties in Dapper

最后都变了- 提交于 2019-12-01 04:14:38
In Dapper ( http://code.google.com/p/dapper-dot-net/ ), is there a way to ignore properties in the model class, namely when using the Insert extension method? My model class has a set of computed properties which are not persisted in the associated table. Thanks. Pedro Well, Dapper has no Insert extension method, that is in dapper.contrib, dapper extensions or dapper rainbow. Dapper itself allows you to do: Animal a = new Animal {Age = 10, Family = "Canine"} // only insert Age cnn.Execute("insert Animal(Age) values (@Age)", a); To work around for some of the extension classes you can sometimes

Get value of Oracle OUT parameter from a stored procedure call using Dapper.NET

拜拜、爱过 提交于 2019-12-01 03:35:24
Edit: Using the Execute method instead of the Query / QueryMultiple methods, my OUT_SUCCESS parameter now has an AttachedParam with with an OracleParameter that has the returned value. So this would work if, for instance, I only needed to retrieve non-cursors parameters. Then I could use Execute for procedures with all non-cursor output parameters and Query / QueryMultiple for procedures with only cursor output parameters. But what if I need to call a stored procedure that has both cursor and non-cursor output parameters, as is often the case? Using Dapper.NET and the OracleDynamicParameters

常用的.NET开源项目

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 02:45:46
综合类 微软企业库 微软官方出品,是为了协助开发商解决企业级应用开发过程中所面临的一系列共性的问题, 如安全(Security)、日志(Logging)、数据访问(Data Access)、配置管理(Configuration Manage)等,并将这些广泛使用的应用程序块集成封装至一个叫企业库的程序包中 CommonLibrary.net 一个帮助类库,包含了ActiveRecord, Csv, Command Line Parsing, Configuration, Validation, Logging, Collections, Authentication等等 Castle 一个传统的综合类库,包含IOC容器,基于ActiveRecord模式的ORM,类MVC框架,核心,现在用的比较多的是核心Castle.Core, 里面包含了基于虚拟工厂的日志抽象,动态代理DynamicProxy,Dictionary Adapter(可以将一个接口转化为强类型的Dictionary对象,具体大家可以查一查,某些场景下很有用 IOC容器 Autofac 我最喜欢的一个IOC容器,特性丰富,除了IOC的基本功能外,还提供模块化和程序集扫描,内置了很多有用的扩展(Lazy,Func,Owned,IEnumrable)等等,而且对asp.net,mvc,mef,wcf

How to use Dapper with MS SQL Server (2012) Geospatial / SQLGeography Column

丶灬走出姿态 提交于 2019-12-01 02:24:00
问题 I have a SQL Server 2012 database with a table that contains a geography column and I want to use Dapper in a .Net application working with that database, but as far as I can tell and see in the Dapper code, "only" Entity Framework's DBGeography type is supported, the underlying SQLGeography data type has no other mentioning in the repository. Can Dapper handle these column types 'magically' nevertheless or would I have to explicitly write a Dapper.SqlMapper.TypeHandler for these? 回答1:

Get Multiple Connection Strings in appsettings.json without EF

旧巷老猫 提交于 2019-12-01 02:12:41
问题 Just starting playing with the .Net Core RC2 by migrating a current MVC .Net app I developed. It looks like to me because of the way that configuration is handled with appsettings.json that if I have multiple connection strings I either have to use EF to retrieve a connectionstring or I have to create separate classes named for each connection string. All the examples I see either use EF (which doesn't make sense for me since I will be using Dapper) or the example builds a class named after

Can I map a result to Tuple in Dapper?

萝らか妹 提交于 2019-12-01 02:09:00
I am trying to select a list of 2 integer columns map the results to a Tuple. Just as an example: return connection.Query<Tuple<int,int>>("select id1, id2 from sometable").ToList(); does not work, but the same query does work if I create a class with two integers such as: return connection.Query<BogusClass>("select id1, id2 from sometable").ToList(); public class BogusClass{ public int id1 {get;set;} public int id2 {get;set;} } My preference is not to have to create some bogus class just to get some data to work with. In this case it is two integer columns, but there are other use cases I

Dapper.net Oracle parameter

余生长醉 提交于 2019-12-01 01:49:45
问题 I am trying to use Dapper.net with Oracle. From this post i understood that we could use parameters with no prefixes and dapper would then work for both sql server and oracle I'm having a hard time making it to work without the explicit oracle named parameters prefix : The following query sqlConnection.Query("Select * FROM document WHERE id = param1", new { param1 = 963 }); Throws ORA-00904: "PARAM1": invalid identifier If i try with the @ prefix it throws ORA-00936: missing expression If i