{"id":36924132,"url":"https://github.com/AzThinker/SqlRepoEx","last_synced_at":"2026-01-19T18:00:46.189Z","repository":{"id":65413914,"uuid":"145376361","full_name":"AzThinker/SqlRepoEx","owner":"AzThinker","description":"SqlRepoEx Intuitively build SQL statements using C# Lambda Expressions，it is a simple object mapper for .Net.","archived":false,"fork":false,"pushed_at":"2018-10-18T11:55:43.000Z","size":2417,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-12-28T03:00:35.938Z","etag":null,"topics":["dapper","dapper-extensions","expression-to-sql","lambda","mysql","orm","sql","sqlserver"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AzThinker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-20T06:37:13.000Z","updated_at":"2024-01-14T13:37:54.000Z","dependencies_parsed_at":"2023-01-22T09:45:14.857Z","dependency_job_id":null,"html_url":"https://github.com/AzThinker/SqlRepoEx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AzThinker/SqlRepoEx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzThinker%2FSqlRepoEx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzThinker%2FSqlRepoEx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzThinker%2FSqlRepoEx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzThinker%2FSqlRepoEx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AzThinker","download_url":"https://codeload.github.com/AzThinker/SqlRepoEx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzThinker%2FSqlRepoEx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28578952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T17:42:58.221Z","status":"ssl_error","status_checked_at":"2026-01-19T17:40:54.158Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["dapper","dapper-extensions","expression-to-sql","lambda","mysql","orm","sql","sqlserver"],"created_at":"2026-01-12T19:00:25.487Z","updated_at":"2026-01-19T18:00:46.180Z","avatar_url":"https://github.com/AzThinker.png","language":"C#","readme":"## Features\n1, SqlRepoEx  Intuitively build SQL statements using C# Lambda Expressions，it is a  simple object mapper for .Net.\u003c/br\u003e\n2. SqlRepoEx solves the problem of Lambda to Sql statements. We no longer use strings to join Sql statements.\u003c/br\u003e\n3. SqlRepoEx not only implements the complete statement parser such as Select, Insert, Update, Delete, etc., but also implements clauses such as Select, where, order by, etc., which all support the export of SQL statements, making it easy to splicing SQL statements in complex scenarios.\u003c/br\u003e\n4.SqlRepoEx also provides IExecuteSqlStatement and its implementation class, which appends the SQL statement you want with the WithSql() method and gets the desired result with Go(), just like Go() in other statement parsers;\u003c/br\u003e\n5. SqlRepoEx solves the dialect access of common databases such as Sql Server and MySql, which makes it very easy for us to migrate between Sql Server and MySql. You don't need to care what database you are using.\u003c/br\u003e\n6. SqlRepoEx is fast.The native data access of SqlRepoEx is equal to that of Dapper. In addition, SqlRepoEx can best integrate with Dapper and can easily use Dapper's powerful functions.\u003c/br\u003e\n7. SqlRepoEx itself supports Sql Server and MySql dialect, and supports non-dialect Sql through sqlrepoex.normal. Other data access libraries, such as Dappers, can access most databases.\u003c/br\u003e\n8. In fact, SqlRepoEx parses Lambda and converts it into SQL statements, and you can use any ORM tool that can use SQL to access the data you want.\u003c/br\u003e\n9. SqlRepoEx supports a variety of complex SQL syntax, such as Union,Join, etc. Meanwhile, more complex type results can be expressed through simple Join on statements\u003c/br\u003e\n10, SqlRepoEx not intrusive, only through simple several features, can let the class with the database, there are no complicated XML configuration, also do not need josn configuration, if SqlRepoEx used in the configuration file, that is configured in the database connection string in the configuration file, of course, you can directly specified in the code, which is depending on your use of the data provider.\u003c/br\u003e\n11. SqlRepoEx USES Lambda expressions, so it is very simple for c# programmers. The syntax is very similar to Linq to Sql, but does not depend on the data context, so there is no need to accommodate the database design.\u003c/br\u003e\n12. Most types of SqlRepoEx are rewritable and highly extensible (SqlRepoEx.Adapter.Dapper is a simple but powerful extension).\u003c/br\u003e\n\n## Installation\nNuGet library that you can add in to your project\u003c/br\u003e\n\n## For Inline access Dapper\n\n[SqlRepoEx.Adapter.Dapper](https://www.nuget.org/packages/SqlRepoEx.Adapter.Dapper/)\u003c/br\u003e\n\nFor SQL Server ,Use static mode(WinForm,Asp.Net Core etc.)\n\n[SqlRepoEx.MsSql.Static](https://www.nuget.org/packages/SqlRepoEx.MsSql.Static/)\u003c/br\u003e\n\nFor SQL Server ,Use Autofac mode(WinForm,Asp.Net Core etc.)\n\n[SqlRepoEx.MsSql.Autofac](https://www.nuget.org/packages/SqlRepoEx.MsSql.Autofac/)\u003c/br\u003e\n\nFor SQL Server ,Use ServiceCollection mode ( Asp.Net Core etc.)\n\n[SqlRepoEx.MsSql.ServiceCollection](https://www.nuget.org/packages/SqlRepoEx.MsSql.ServiceCollection/)\u003c/br\u003e\n\nFor MySql ,Use static mode(WinForm,Asp.Net Core etc.)\n[SqlRepoEx.MySql.Static](https://www.nuget.org/packages/SqlRepoEx.MySql.Static/)\u003c/br\u003e\n\nFor MySql ,Use ServiceCollection mode(Asp.Net Core etc.) \n\n[SqlRepoEx.MySql.ServiceCollection](https://www.nuget.org/packages/SqlRepoEx.MySql.ServiceCollection/)\u003c/br\u003e\n\nFor SQL Server ,Use Autofac mode(WinForm,Asp.Net Core etc.)\n[SqlRepoEx.MySql.Autofac](https://www.nuget.org/packages/SqlRepoEx.MySql.Autofac/)\u003c/br\u003e\n\n## Example\n``` c#\npublic class GettingStarted\n{\n    private IRepositoryFactory repositoryFactory;\n\n    public GettingStarted(IRepositoryFactory repositoryFactory)\n    {\n        this.repositoryFactory = repositoryFactory;\n    }\n\n    public void DoIt()\n    {\n         IRepository\u003cToDo\u003e repository = repositoryFactory.Create\u003cToDo\u003e();\n            var results = repository.Query()\n                         .Select(e =\u003e e.Id, e =\u003e e.Task, e =\u003e e.CreatedDate);\n\t results = results.Where(e =\u003e e.IsCompleted == false);\n\t results = results.Where(e =\u003e e.Id \u003e3);\n\t var values=result.Go();\n    }\n}\n```\nGenerates the following SQL statement and maps the results back to the list of ToDo objects.\n``` sql\n\nSELECT [dbo].[ToDo].[Id]\n, [dbo].[ToDo].[Task]\n, [dbo].[ToDo].[CreatedDate]\nFROM [dbo].[ToDo]\nWHERE ([dbo].[ToDo].[IsCompleted] = 0)\nAnd ([dbo].[ToDo].[Id] \u003e 3);\n\n```  \n\n## Page(SQL Server,Note that Order by is required)\n\n```\nvar repository = MsSqlRepoFactory.Create\u003cToDo\u003e();\n var results2 = repository.Query().Page(10, 3).OrderBy(e =\u003e e.Id).Go();\n```\nGenerates the following SQL statement and maps the results back to the list of ToDo objects.\n``` sql\nSELECT TOP (10) * FROM (SELECT row_number() OVER (\nORDER BY [dbo].[ToDo].[Id] ASC) as row_number,[dbo].[ToDo].[CreatedDate]\n, [dbo].[ToDo].[IsCompleted]\n, [dbo].[ToDo].[Task]\n, [dbo].[ToDo].[Id]\nFROM [dbo].[ToDo])As __Page_Query WHERE row_number \u003e 20;\n\n```\n## Union\n\n``` C#\n var repository = MsSqlRepoFactory.Create\u003cToDo\u003e();\n            var results = repository.Query().Select(e =\u003e e.Id, e =\u003e e.Task);\n            var results5 = repository.Query().Select(e =\u003e e.Id, e =\u003e e.Task)\n                          .Where(c =\u003e c.Id \u003e 0 \u0026\u0026 c.Id \u003c 7);\n            var results6 = repository.Query()\n                           .Select(e =\u003e e.Id, e =\u003e e.Task)\n                          .Where(c =\u003e c.Id \u003e 10 \u0026\u0026 c.Id \u003c 15);\n            var results2 = results.Union(new List\u003cUnionSql\u003e {\n                     UnionSql.New(  results5,UnionType.Union ),\n                     UnionSql.New(  results6,UnionType.Union )  })\n```\nGenerates the following SQL statement and maps the results back to the list of ToDo objects.\n``` sql\nSELECT [_this_is_union].[Id]\n, [_this_is_union].[Task]\nFROM ( SELECT [dbo].[ToDo].[Id]\n, [dbo].[ToDo].[Task]\nFROM [dbo].[ToDo]\nWHERE ((([dbo].[ToDo].[Id] \u003e 0) and ([dbo].[ToDo].[Id] \u003c 7)))\nUNION\n SELECT [dbo].[ToDo].[Id]\n, [dbo].[ToDo].[Task]\nFROM [dbo].[ToDo]\nWHERE ((([dbo].[ToDo].[Id] \u003e 10) and ([dbo].[ToDo].[Id] \u003c 15))) )\nAS  _this_is_union\n```\n## Join\n```\n var repository = MsSqlRepoFactory.Create\u003cToDo\u003e();\n var results2 = repository.Query().Select(c=\u003ec.Id,c=\u003ec.Task,c=\u003ec.Remark)\n                           .LeftOuterJoin\u003cTaskRemark\u003e()\n\t\t\t   // add additional conditions. If the main selection has this property, query what is set in this sentence\n                           .On\u003cTaskRemark\u003e((r, l) =\u003e r.Task == l.Task, l =\u003e l.Remark).Go();\n \n```\nGenerates the following SQL statement and maps the results back to the list of ToDo objects.\u003c/br\u003e\n\n``` sql\n\nSELECT [dbo].[ToDo].[Id]\n, [dbo].[ToDo].[Task]\n, [dbo].[TaskRemark].[Remark]\nFROM [dbo].[ToDo]\nLEFT OUTER JOIN [dbo].[TaskRemark]\nON [dbo].[ToDo].[Task] = [dbo].[TaskRemark].[Task];\n```\n\n## For   Dapper \u003c/br\u003e\n(Notice, Only Insert,Update Support   ParamSqlWithEntity() and ParamSql() method）\u003c/br\u003e\n```\n\tvar repository = MySqlRepoFactory.Create\u003cToDo\u003e();\n            var results1 = repository.Query().Where(c =\u003e c.Id == 2).Go().FirstOrDefault();\n            results1.Task = \"B21\";\n            var rest2=   repository.Update().For(results1);\n            var rest3 = rest2.ParamSqlWithEntity();\n\t    // Get  IDbConnection\n            IDbConnection dbConnection = repository.GetConnectionProvider.GetDbConnection;\n\t    // Use Dapper\n            dbConnection.Execute(rest3.paramsql, rest3.entity);\n```\nGenerates the following SQL statement and maps the results back to the list of ToDo objects.\n``` sql\nUPDATE  `ToDo`\nSET CreatedDate  = @CreatedDate, IsCompleted  = @IsCompleted, Task  = @Task\nWHERE Id  = @Id;\n```\n## For Inline access Dapper\n\n```\n           string ConnectionString = \"datasource=127.0.0.1;username=test;password=test;database=sqlrepotest;charset=gb2312;SslMode = none;\";\n            var connectionProvider = new  ConnectionStringConnectionProvider(ConnectionString);\n            MySqlRepoFactory.UseConnectionProvider(connectionProvider);\n            MySqlRepoFactory.UseStatementExecutor(new DapperStatementExecutor(connectionProvider));\n            MySqlRepoFactory.UseDataReaderEntityMapper(new DapperEntityMapper());\n            MySqlRepoFactory.UseWritablePropertyMatcher(new SimpleWritablePropertyMatcher());\n```\n","funding_links":[],"categories":["C# #"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAzThinker%2FSqlRepoEx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAzThinker%2FSqlRepoEx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAzThinker%2FSqlRepoEx/lists"}