dapper

Create a DbContext that handle a DatabaseFactory to use DapperExtensions more easily

纵饮孤独 提交于 2019-12-20 04:10:21
问题 This days I try to create an abstract base repository using some basic CRUD functions proposed by DapperExtensions. But the code given as an exemple use a SqlConnection which is made to connect to a SQL Server database. I want to be able to connect to all kind of Database (SQL Server, MySql, etc...). Also their code sample is repeated for each CRUD function as the code below show using (SqlConnection cn = new SqlConnection(_connectionString)) { cn.Open(); //Code doing something here... cn

Illegal attempt to use Text/Byte host variable - Inserting into TEXT column

最后都变了- 提交于 2019-12-20 03:54:07
问题 Trying to insert into a table (Text Column) via Dapper, and getting the error from Informix: Illegal attempt to use Text/Byte host variable I have written a small program to simulate this, and I am still up against problems. We cannot currently use the Informix drivers, as they do not suit our needs. using Dapper; using System; using System.Data.Odbc; namespace DapperParamsTest { class Program { static void Main(string[] args) { OdbcConnection conn = new System.Data.Odbc.OdbcConnection(

Comparing QUERY and EXECUTE in Dapper

雨燕双飞 提交于 2019-12-19 19:44:57
问题 I would like to ask if what is the best to use when INSERTING, UPDATING, DELETING, REMOVING, QUERY SPECIFIC DATA using DAPPER? I'm really confused in using EXECUTE and QUERY command in DAPPER.. 回答1: This should not be confusing at all, especially if you look at the signature of the methods exposed by the Dapper (as per documentation): public static IEnumerable<T> Query<T>(this IDbConnection cnn, string sql, object param = null, SqlTransaction transaction = null, bool buffered = true) Query

Comparing QUERY and EXECUTE in Dapper

泪湿孤枕 提交于 2019-12-19 19:44:09
问题 I would like to ask if what is the best to use when INSERTING, UPDATING, DELETING, REMOVING, QUERY SPECIFIC DATA using DAPPER? I'm really confused in using EXECUTE and QUERY command in DAPPER.. 回答1: This should not be confusing at all, especially if you look at the signature of the methods exposed by the Dapper (as per documentation): public static IEnumerable<T> Query<T>(this IDbConnection cnn, string sql, object param = null, SqlTransaction transaction = null, bool buffered = true) Query

Dapper multiselect: Nested class primary key doesn't map unless using “AS”

[亡魂溺海] 提交于 2019-12-19 09:25:07
问题 I have two classes: class Foo{ public int FooId { get; set; } ... public Bar Bar { get; set } } class Bar{ public int BarId { get; set; } public int FooId { get; set } ... } when i then run the query like this: sqlConnection.Query<Foo, Bar, Foo>( "SELECT * FROM Foo JOIN Bar ON Foo.FooId = Bar.FooId", (foo, bar) => { foo.Bar = bar; return foo; }, splitOn: "FooId"); the result would then be that all properties on both Foo and Bar will map up Except for Bar.BarId. After checking the column name

Dapper, ODATA, and IQueryable in ASP.NET

ぐ巨炮叔叔 提交于 2019-12-19 08:05:59
问题 I saw the great performance of Dapper and some samples of how to use it. I was wondering if I can use it to provide IQueryable data and integrate it with UI layer using ODATA to transfer data to the UI (like grids, lists,...). Is there any way to return Dapper objects AsQueryable instead of IEnumerable to query using ODATA? 回答1: No, not really. Well, you can wrap any sequence with .AsQueryable() if you really want, but it will just be using LINQ-to-Objects. Dapper is deliberately simple; it

Dapper, ODATA, and IQueryable in ASP.NET

偶尔善良 提交于 2019-12-19 08:05:50
问题 I saw the great performance of Dapper and some samples of how to use it. I was wondering if I can use it to provide IQueryable data and integrate it with UI layer using ODATA to transfer data to the UI (like grids, lists,...). Is there any way to return Dapper objects AsQueryable instead of IEnumerable to query using ODATA? 回答1: No, not really. Well, you can wrap any sequence with .AsQueryable() if you really want, but it will just be using LINQ-to-Objects. Dapper is deliberately simple; it

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

折月煮酒 提交于 2019-12-19 05:51:17
问题 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

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

大憨熊 提交于 2019-12-19 05:50:30
问题 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

Can I map a result to Tuple in Dapper?

怎甘沉沦 提交于 2019-12-19 05:02:36
问题 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