Commit 8f13e220 authored by Nick Craver's avatar Nick Craver

Add packages to README

parent e8bd27d8
...@@ -4,9 +4,22 @@ Dapper - a simple object mapper for .Net ...@@ -4,9 +4,22 @@ Dapper - a simple object mapper for .Net
Release Notes Release Notes
------------- -------------
Located at [stackexchange.github.io/Dapper](https://stackexchange.github.io/Dapper/) Located at [stackexchange.github.io/Dapper](https://stackexchange.github.io/Dapper/)
Packages
--------
MyGet Pre-release feed: https://www.myget.org/gallery/dapper
| Package | NuGet Stable | NuGet Pre-release | Downloads | MyGet |
| ------- | ------------ | ----------------- | --------- | ----- |
| [Dapper](https://www.nuget.org/packages/Dapper/) | [![Dapper](https://img.shields.io/nuget/v/Dapper.svg)](https://www.nuget.org/packages/Dapper/) | [![Dapper](https://img.shields.io/nuget/vpre/Dapper.svg)](https://www.nuget.org/packages/Dapper/) | [![Dapper](https://img.shields.io/nuget/dt/Dapper.svg)](https://www.nuget.org/packages/Dapper/) | [![Dapper MyGet](https://img.shields.io/myget/dapper/vpre/Dapper.svg)](https://www.myget.org/feed/dapper/package/nuget/Dapper) |
| [Dapper.Contrib](https://www.nuget.org/packages/Dapper.Contrib/) | [![Dapper.Contrib](https://img.shields.io/nuget/v/Dapper.Contrib.svg)](https://www.nuget.org/packages/Dapper.Contrib/) | [![Dapper.Contrib](https://img.shields.io/nuget/vpre/Dapper.Contrib.svg)](https://www.nuget.org/packages/Dapper.Contrib/) | [![Dapper.Contrib](https://img.shields.io/nuget/dt/Dapper.Contrib.svg)](https://www.nuget.org/packages/Dapper.Contrib/) | [![Dapper.Contrib MyGet](https://img.shields.io/myget/dapper/vpre/Dapper.Contrib.svg)](https://www.myget.org/feed/dapper/package/nuget/Dapper.Contrib) |
| [Dapper.EntityFramework](https://www.nuget.org/packages/Dapper.EntityFramework/) | [![Dapper.EntityFramework](https://img.shields.io/nuget/v/Dapper.EntityFramework.svg)](https://www.nuget.org/packages/Dapper.EntityFramework/) | [![Dapper.EntityFramework](https://img.shields.io/nuget/vpre/Dapper.EntityFramework.svg)](https://www.nuget.org/packages/Dapper.EntityFramework/) | [![Dapper.EntityFramework](https://img.shields.io/nuget/dt/Dapper.EntityFramework.svg)](https://www.nuget.org/packages/Dapper.EntityFramework/) | [![Dapper.EntityFramework MyGet](https://img.shields.io/myget/dapper/vpre/Dapper.EntityFramework.svg)](https://www.myget.org/feed/dapper/package/nuget/Dapper.EntityFramework) |
| [Dapper.EntityFramework.StrongName](https://www.nuget.org/packages/Dapper.EntityFramework.StrongName/) | [![Dapper.EntityFramework.StrongName](https://img.shields.io/nuget/v/Dapper.EntityFramework.StrongName.svg)](https://www.nuget.org/packages/Dapper.EntityFramework.StrongName/) | [![Dapper.EntityFramework.StrongName](https://img.shields.io/nuget/vpre/Dapper.EntityFramework.StrongName.svg)](https://www.nuget.org/packages/Dapper.EntityFramework.StrongName/) | [![Dapper.EntityFramework.StrongName](https://img.shields.io/nuget/dt/Dapper.EntityFramework.StrongName.svg)](https://www.nuget.org/packages/Dapper.EntityFramework.StrongName/) | [![Dapper.EntityFramework.StrongName MyGet](https://img.shields.io/myget/dapper/vpre/Dapper.EntityFramework.StrongName.svg)](https://www.myget.org/feed/dapper/package/nuget/Dapper.EntityFramework.StrongName) |
| [Dapper.Rainbow](https://www.nuget.org/packages/Dapper.Rainbow/) | [![Dapper.Rainbow](https://img.shields.io/nuget/v/Dapper.Rainbow.svg)](https://www.nuget.org/packages/Dapper.Rainbow/) | [![Dapper.Rainbow](https://img.shields.io/nuget/vpre/Dapper.Rainbow.svg)](https://www.nuget.org/packages/Dapper.Rainbow/) | [![Dapper.Rainbow](https://img.shields.io/nuget/dt/Dapper.Rainbow.svg)](https://www.nuget.org/packages/Dapper.Rainbow/) | [![Dapper.Rainbow MyGet](https://img.shields.io/myget/dapper/vpre/Dapper.Rainbow.svg)](https://www.myget.org/feed/dapper/package/nuget/Dapper.Rainbow) |
| [Dapper.SqlBuilder](https://www.nuget.org/packages/Dapper.SqlBuilder/) | [![Dapper.SqlBuilder](https://img.shields.io/nuget/v/Dapper.SqlBuilder.svg)](https://www.nuget.org/packages/Dapper.SqlBuilder/) | [![Dapper.SqlBuilder](https://img.shields.io/nuget/vpre/Dapper.SqlBuilder.svg)](https://www.nuget.org/packages/Dapper.SqlBuilder/) | [![Dapper.SqlBuilder](https://img.shields.io/nuget/dt/Dapper.SqlBuilder.svg)](https://www.nuget.org/packages/Dapper.SqlBuilder/) | [![Dapper.SqlBuilder MyGet](https://img.shields.io/myget/dapper/vpre/Dapper.SqlBuilder.svg)](https://www.myget.org/feed/dapper/package/nuget/Dapper.SqlBuilder) |
| [Dapper.StrongName](https://www.nuget.org/packages/Dapper.StrongName/) | [![Dapper.StrongName](https://img.shields.io/nuget/v/Dapper.StrongName.svg)](https://www.nuget.org/packages/Dapper.StrongName/) | [![Dapper.StrongName](https://img.shields.io/nuget/vpre/Dapper.StrongName.svg)](https://www.nuget.org/packages/Dapper.StrongName/) | [![Dapper.StrongName](https://img.shields.io/nuget/dt/Dapper.StrongName.svg)](https://www.nuget.org/packages/Dapper.StrongName/) | [![Dapper.StrongName MyGet](https://img.shields.io/myget/dapper/vpre/Dapper.StrongName.svg)](https://www.myget.org/feed/dapper/package/nuget/Dapper.StrongName) |
Features Features
-------- --------
...@@ -31,8 +44,8 @@ public class Dog ...@@ -31,8 +44,8 @@ public class Dog
public float? Weight { get; set; } public float? Weight { get; set; }
public int IgnoredProperty { get { return 1; } } public int IgnoredProperty { get { return 1; } }
} }
var guid = Guid.NewGuid(); var guid = Guid.NewGuid();
var dog = connection.Query<Dog>("select Age = @Age, Id = @Id", new { Age = (int?)null, Id = guid }); var dog = connection.Query<Dog>("select Age = @Age, Id = @Id", new { Age = (int?)null, Id = guid });
...@@ -71,12 +84,12 @@ Example usage: ...@@ -71,12 +84,12 @@ Example usage:
```csharp ```csharp
var count = connection.Execute(@" var count = connection.Execute(@"
set nocount on set nocount on
create table #t(i int) create table #t(i int)
set nocount off set nocount off
insert #t insert #t
select @a a union all select @b select @a a union all select @b
set nocount on set nocount on
drop table #t", new {a=1, b=2 }); drop table #t", new {a=1, b=2 });
Assert.Equal(2, count); Assert.Equal(2, count);
``` ```
...@@ -111,10 +124,10 @@ The performance tests are broken in to 3 lists: ...@@ -111,10 +124,10 @@ The performance tests are broken in to 3 lists:
| Method | Duration | Remarks | | Method | Duration | Remarks |
| --------------------------------------------------- | -------- | ------- | | --------------------------------------------------- | -------- | ------- |
| Hand coded (using a `SqlDataReader`) | 47ms | | Hand coded (using a `SqlDataReader`) | 47ms |
| Dapper `ExecuteMapperQuery` | 49ms | | Dapper `ExecuteMapperQuery` | 49ms |
| [ServiceStack.OrmLite](https://github.com/ServiceStack/ServiceStack.OrmLite) (QueryById) | 50ms | | [ServiceStack.OrmLite](https://github.com/ServiceStack/ServiceStack.OrmLite) (QueryById) | 50ms |
| [PetaPoco](http://www.toptensoftware.com/petapoco/) | 52ms | [Can be faster](http://web.archive.org/web/20170921124755/http://www.toptensoftware.com/blog/posts/94-PetaPoco-More-Speed) | | [PetaPoco](https://github.com/CollaboratingPlatypus/PetaPoco) | 52ms | [Can be faster](https://web.archive.org/web/20170921124755/http://www.toptensoftware.com/blog/posts/94-PetaPoco-More-Speed) |
| BLToolkit | 80ms | | BLToolkit | 80ms |
| SubSonic CodingHorror | 107ms | | SubSonic CodingHorror | 107ms |
| NHibernate SQL | 104ms | | NHibernate SQL | 104ms |
...@@ -153,7 +166,7 @@ Parameterized queries ...@@ -153,7 +166,7 @@ Parameterized queries
Parameters are passed in as anonymous classes. This allow you to name your parameters easily and gives you the ability to simply cut-and-paste SQL snippets and run them in your db platform's Query analyzer. Parameters are passed in as anonymous classes. This allow you to name your parameters easily and gives you the ability to simply cut-and-paste SQL snippets and run them in your db platform's Query analyzer.
```csharp ```csharp
new {A = 1, B = "b"} // A will be mapped to the param @A, B to the param @B new {A = 1, B = "b"} // A will be mapped to the param @A, B to the param @B
``` ```
List Support List Support
...@@ -215,7 +228,7 @@ class User ...@@ -215,7 +228,7 @@ class User
Now let us say that we want to map a query that joins both the posts and the users table. Until now if we needed to combine the result of 2 queries, we'd need a new object to express it but it makes more sense in this case to put the `User` object inside the `Post` object. Now let us say that we want to map a query that joins both the posts and the users table. Until now if we needed to combine the result of 2 queries, we'd need a new object to express it but it makes more sense in this case to put the `User` object inside the `Post` object.
This is the user case for multi mapping. You tell dapper that the query returns a `Post` and a `User` object and then give it a function describing what you want to do with each of the rows containing both a `Post` and a `User` object. In our case, we want to take the user object and put it inside the post object. So we write the function: This is the user case for multi mapping. You tell dapper that the query returns a `Post` and a `User` object and then give it a function describing what you want to do with each of the rows containing both a `Post` and a `User` object. In our case, we want to take the user object and put it inside the post object. So we write the function:
```csharp ```csharp
(post, user) => { post.Owner = user; return post; } (post, user) => { post.Owner = user; return post; }
...@@ -230,11 +243,11 @@ The 3 type arguments to the `Query` method specify what objects dapper should us ...@@ -230,11 +243,11 @@ The 3 type arguments to the `Query` method specify what objects dapper should us
Everything put together, looks like this: Everything put together, looks like this:
```csharp ```csharp
var sql = var sql =
@"select * from #Posts p @"select * from #Posts p
left join #Users u on u.Id = p.OwnerId left join #Users u on u.Id = p.OwnerId
Order by p.Id"; Order by p.Id";
var data = connection.Query<Post, User, Post>(sql, (post, user) => { post.Owner = user; return post;}); var data = connection.Query<Post, User, Post>(sql, (post, user) => { post.Owner = user; return post;});
var post = data.First(); var post = data.First();
...@@ -253,19 +266,19 @@ Dapper allows you to process multiple result grids in a single query. ...@@ -253,19 +266,19 @@ Dapper allows you to process multiple result grids in a single query.
Example: Example:
```csharp ```csharp
var sql = var sql =
@" @"
select * from Customers where CustomerId = @id select * from Customers where CustomerId = @id
select * from Orders where CustomerId = @id select * from Orders where CustomerId = @id
select * from Returns where CustomerId = @id"; select * from Returns where CustomerId = @id";
using (var multi = connection.QueryMultiple(sql, new {id=selectedId})) using (var multi = connection.QueryMultiple(sql, new {id=selectedId}))
{ {
var customer = multi.Read<Customer>().Single(); var customer = multi.Read<Customer>().Single();
var orders = multi.Read<Order>().ToList(); var orders = multi.Read<Order>().ToList();
var returns = multi.Read<Return>().ToList(); var returns = multi.Read<Return>().ToList();
... ...
} }
``` ```
Stored Procedures Stored Procedures
...@@ -273,7 +286,7 @@ Stored Procedures ...@@ -273,7 +286,7 @@ Stored Procedures
Dapper fully supports stored procs: Dapper fully supports stored procs:
```csharp ```csharp
var user = cnn.Query<User>("spGetUser", new {Id = 1}, var user = cnn.Query<User>("spGetUser", new {Id = 1},
commandType: CommandType.StoredProcedure).SingleOrDefault(); commandType: CommandType.StoredProcedure).SingleOrDefault();
``` ```
...@@ -285,10 +298,10 @@ p.Add("@a", 11); ...@@ -285,10 +298,10 @@ p.Add("@a", 11);
p.Add("@b", dbType: DbType.Int32, direction: ParameterDirection.Output); p.Add("@b", dbType: DbType.Int32, direction: ParameterDirection.Output);
p.Add("@c", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue); p.Add("@c", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue);
cnn.Execute("spMagicProc", p, commandType: CommandType.StoredProcedure); cnn.Execute("spMagicProc", p, commandType: CommandType.StoredProcedure);
int b = p.Get<int>("@b"); int b = p.Get<int>("@b");
int c = p.Get<int>("@c"); int c = p.Get<int>("@c");
``` ```
Ansi Strings and varchar Ansi Strings and varchar
...@@ -318,9 +331,9 @@ using (var reader = connection.ExecuteReader("select * from Shapes")) ...@@ -318,9 +331,9 @@ using (var reader = connection.ExecuteReader("select * from Shapes"))
var circleParser = reader.GetRowParser<IShape>(typeof(Circle)); var circleParser = reader.GetRowParser<IShape>(typeof(Circle));
var squareParser = reader.GetRowParser<IShape>(typeof(Square)); var squareParser = reader.GetRowParser<IShape>(typeof(Square));
var triangleParser = reader.GetRowParser<IShape>(typeof(Triangle)); var triangleParser = reader.GetRowParser<IShape>(typeof(Triangle));
var typeColumnIndex = reader.GetOrdinal("Type"); var typeColumnIndex = reader.GetOrdinal("Type");
while (reader.Read()) while (reader.Read())
{ {
IShape shape; IShape shape;
...@@ -339,7 +352,7 @@ using (var reader = connection.ExecuteReader("select * from Shapes")) ...@@ -339,7 +352,7 @@ using (var reader = connection.ExecuteReader("select * from Shapes"))
default: default:
throw new NotImplementedException(); throw new NotImplementedException();
} }
shapes.Add(shape); shapes.Add(shape);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment