{"id":13458299,"url":"https://github.com/tmsmith/Dapper-Extensions","last_synced_at":"2025-03-24T15:31:07.095Z","repository":{"id":40523968,"uuid":"2682189","full_name":"tmsmith/Dapper-Extensions","owner":"tmsmith","description":"Dapper Extensions is a small library that complements Dapper by adding basic CRUD operations (Get, Insert, Update, Delete) for your POCOs. For more advanced querying scenarios, Dapper Extensions provides a predicate system. The goal of this library is to keep your POCOs pure by not requiring any attributes or base class inheritance.","archived":false,"fork":false,"pushed_at":"2024-02-06T22:02:55.000Z","size":27003,"stargazers_count":1788,"open_issues_count":79,"forks_count":585,"subscribers_count":137,"default_branch":"master","last_synced_at":"2024-12-07T09:11:56.940Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmsmith.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-10-31T17:10:10.000Z","updated_at":"2024-12-05T05:52:43.000Z","dependencies_parsed_at":"2024-01-05T20:51:53.565Z","dependency_job_id":"b5033fcd-5082-461c-bd8d-3f002b3257a6","html_url":"https://github.com/tmsmith/Dapper-Extensions","commit_stats":{"total_commits":284,"total_committers":46,"mean_commits":6.173913043478261,"dds":0.6549295774647887,"last_synced_commit":"ae7441406ce5eca803cedc0ab1f241b0ab460eaf"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmsmith%2FDapper-Extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmsmith%2FDapper-Extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmsmith%2FDapper-Extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmsmith%2FDapper-Extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmsmith","download_url":"https://codeload.github.com/tmsmith/Dapper-Extensions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244973714,"owners_count":20541025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T09:00:50.106Z","updated_at":"2025-03-24T15:31:07.069Z","avatar_url":"https://github.com/tmsmith.png","language":"C#","readme":"\u003ca href=\"https://www.nuget.org/packages/DapperExtensions\"\u003e\u003cimg src=\"https://img.shields.io/nuget/v/DapperExtensions.svg\" alt=\"NuGet Version\" /\u003e\u003c/a\u003e \n\u003ca href=\"https://www.nuget.org/packages/DapperExtensions\"\u003e\u003cimg src=\"https://img.shields.io/nuget/dt/DapperExtensions.svg\" alt=\"NuGet Download Count\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/tmsmith/github-readme-stats/workflows\"\u003e\u003cimg src=\"https://github.com/tmsmith/Dapper-Extensions/actions/workflows/codeql-analysis.yml/badge.svg\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/tmsmith/github-readme-stats/issues\"\u003e\u003cimg alt=\"GitHub issues\" src=\"https://img.shields.io/github/issues/tmsmith/Dapper-Extensions\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/tmsmith/github-readme-stats/pulls\"\u003e\u003cimg alt=\"GitHub pull requests\" src=\"https://img.shields.io/github/issues-pr/tmsmith/Dapper-Extensions\"\u003e\u003c/a\u003e\n\n\u003c!--\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/tmsmith/github-readme-stats/workflows\"\u003e\n    \u003cimg src=\"https://github.com/tmsmith/Dapper-Extensions/actions/workflows/TestAndPublish.yml/badge.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/tmsmith/github-readme-stats/issues\"\u003e\u003cimg alt=\"GitHub closed issues\" src=\"https://img.shields.io/github/issues-closed/tmsmith/Dapper-Extensions\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/tmsmith/github-readme-stats/pulls\"\u003e\n    \u003cimg alt=\"GitHub closed pull requests\" src=\"https://img.shields.io/github/issues-pr-closed/tmsmith/Dapper-Extensions\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e--\u003e\n\n# Introduction\n\nDapper Extensions is a small library that complements [Dapper](https://github.com/SamSaffron/dapper-dot-net) by adding basic CRUD operations (Get, Insert, Update, Delete) for your POCOs. For more advanced querying scenarios, Dapper Extensions provides a predicate system. The goal of this library is to keep your POCOs pure by not requiring any attributes or base class inheritance.\n\nCustomized mappings are achieved through [ClassMapper](https://github.com/tmsmith/Dapper-Extensions/wiki/AutoClassMapper). \n\n**Important**: This library is a separate effort from Dapper.Contrib (a sub-system of the [Dapper](https://github.com/SamSaffron/dapper-dot-net) project).\n**Important**: Check our projects list to see the plans for the next releases.\n\nFeatures\n--------\n* Zero configuration out of the box.\n* Automatic mapping of POCOs for Get, Insert, Update, and Delete operations.\n* GetList, Count methods for more advanced scenarios.\n* GetPage for returning paged result sets.\n* Automatic support for Guid and Integer [primary keys](https://github.com/tmsmith/Dapper-Extensions/wiki/KeyTypes) (Includes manual support for other key types).\n* Pure POCOs through use of [ClassMapper](https://github.com/tmsmith/Dapper-Extensions/wiki/AutoClassMapper) (_Attribute Free!_).\n* Customized entity-table mapping through the use of [ClassMapper](https://github.com/tmsmith/Dapper-Extensions/wiki/AutoClassMapper).\n* Composite Primary Key support.\n* Singular and Pluralized table name support (Singular by default).\n* Easy-to-use [Predicate System](https://github.com/tmsmith/Dapper-Extensions/wiki/Predicates) for more advanced scenarios.\n* Properly escapes table/column names in generated SQL (Ex: SELECT [FirstName] FROM [Users] WHERE [Users].[UserId] = @UserId_0)\n* Unit test coverage (150+ Unit Tests)\n\nNaming Conventions\n------------------\n* POCO names should match the table name in the database. Pluralized table names are supported through the PlurizedAutoClassMapper.\n* POCO property names should match each column name in the table.\n* By convention, the primary key should be named Id. Using another name is supported through custom mappings.\n\n# Installation\n\nFor more information, please view our [Getting Started](https://github.com/tmsmith/Dapper-Extensions/wiki/Getting-Started) guide.\n\nhttp://nuget.org/List/Packages/DapperExtensions\n\n```\nPM\u003e Install-Package DapperExtensions\n```\n\n# Examples\nThe following examples will use a Person POCO defined as:\n\n```c#\npublic class Person\n{\n    public int Id { get; set; }\n    public string FirstName { get; set; }\n    public string LastName { get; set; }\n    public bool Active { get; set; }\n    public DateTime DateCreated { get; set; }\n}\n```\n\n\n## Get Operation\n\n```c#\nusing (SqlConnection cn = new SqlConnection(_connectionString))\n{\n    cn.Open();\n    int personId = 1;\n    Person person = cn.Get\u003cPerson\u003e(personId);\t\n    cn.Close();\n}\n```\n\n## Simple Insert Operation\n\n```c#\nusing (SqlConnection cn = new SqlConnection(_connectionString))\n{\n    cn.Open();\n    Person person = new Person { FirstName = \"Foo\", LastName = \"Bar\" };\n    int id = cn.Insert(person);\n    cn.Close();\n}\n```\n\n## Advanced Insert Operation (Composite Key)\n\n```c#\npublic class Car\n{\n    public int ModelId { get; set; }\n    public int Year { get; set; }\n    public string Color { get; set; }\n}\n\n...\n\nusing (SqlConnection cn = new SqlConnection(_connectionString))\n{\n    cn.Open();\n    Car car = new Car { Color = \"Red\" };\n    var multiKey = cn.Insert(car);\n    cn.Close();\n\n    int modelId = multiKey.ModelId;\n    int year = multiKey.Year;\n}\n```\n\n## Simple Update Operation\n\n```c#\nusing (SqlConnection cn = new SqlConnection(_connectionString))\n{\n    cn.Open();\n    int personId = 1;\n    Person person = cn.Get\u003cPerson\u003e(personId);\n    person.LastName = \"Baz\";\n    cn.Update(person);\n    cn.Close();\n}\n```\n\n\n## Simple Delete Operation\n\n```c#\nusing (SqlConnection cn = new SqlConnection(_connectionString))\n{\n    cn.Open();\n    Person person = cn.Get\u003cPerson\u003e(1);\n    cn.Delete(person);\n    cn.Close();\n}\n```\n\n## GetList Operation (with Predicates)\n\n```c#\nusing (SqlConnection cn = new SqlConnection(_connectionString))\n{\n    cn.Open();\n    var predicate = Predicates.Field\u003cPerson\u003e(f =\u003e f.Active, Operator.Eq, true);\n    IEnumerable\u003cPerson\u003e list = cn.GetList\u003cPerson\u003e(predicate);\n    cn.Close();\n}\n```\n\nGenerated SQL\n\n```\nSELECT \n   [Person].[Id]\n , [Person].[FirstName]\n , [Person].[LastName]\n , [Person].[Active]\n , [Person].[DateCreated] \nFROM [Person] \nWHERE ([Person].[Active] = @Active_0)\n```\n\nMore information on predicates can be found in [our wiki](https://github.com/tmsmith/Dapper-Extensions/wiki/Predicates).\n\n\n## Count Operation (with Predicates)\n\n```c#\nusing (SqlConnection cn = new SqlConnection(_connectionString))\n{\n    cn.Open();\n    var predicate = Predicates.Field\u003cPerson\u003e(f =\u003e f.DateCreated, Operator.Lt, DateTime.UtcNow.AddDays(-5));\n    int count = cn.Count\u003cPerson\u003e(predicate);\n    cn.Close();\n}            \n```\n\nGenerated SQL\n\n```\nSELECT \n   COUNT(*) Total \nFROM [Person] \nWHERE ([Person].[DateCreated] \u003c @DateCreated_0)\n```\n\nMore information on predicates can be found in [our wiki](https://github.com/tmsmith/Dapper-Extensions/wiki/Predicates).\n\n\n# License\n\nCopyright 2011 Thad Smith, Page Brooks and contributors\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n\n\n","funding_links":[],"categories":["C\\#","C#","others","ORM","C# #"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmsmith%2FDapper-Extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmsmith%2FDapper-Extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmsmith%2FDapper-Extensions/lists"}