{"id":15002717,"url":"https://github.com/dotnetcore/freesql","last_synced_at":"2025-05-14T07:07:34.880Z","repository":{"id":37628096,"uuid":"162222002","full_name":"dotnetcore/FreeSql","owner":"dotnetcore","description":".NET aot orm, VB.NET/C# orm, Mysql/PostgreSQL/SqlServer/Oracle orm, Sqlite/Firebird/Clickhouse/DuckDB orm, 达梦/金仓/虚谷/翰高/高斯 orm, 神通 orm, 南大通用 orm, 国产 orm, TDengine orm, QuestDB orm, MsAccess orm.","archived":false,"fork":false,"pushed_at":"2025-04-30T13:48:59.000Z","size":22281,"stargazers_count":4216,"open_issues_count":61,"forks_count":872,"subscribers_count":148,"default_branch":"master","last_synced_at":"2025-04-30T14:13:19.923Z","etag":null,"topics":["access","clickhouse","codefirst","dameng","duckdb","firebird","gbase","hacktoberfest","highgo","kingbase","mysql","odbc","oracle","orm","postgresql","questdb","shentongdata","sqlite","sqlserver","xugu"],"latest_commit_sha":null,"homepage":"https://freesql.net","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/dotnetcore.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-12-18T03:02:51.000Z","updated_at":"2025-04-30T13:49:03.000Z","dependencies_parsed_at":"2022-07-13T14:21:02.337Z","dependency_job_id":"98680713-6727-46f3-9b47-a97eaef349b4","html_url":"https://github.com/dotnetcore/FreeSql","commit_stats":{"total_commits":2490,"total_committers":42,"mean_commits":"59.285714285714285","dds":0.5236947791164659,"last_synced_commit":"e37a0437c6fcf7f8ba0ef96062e10d0a11722c19"},"previous_names":["2881099/freesql"],"tags_count":105,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnetcore%2FFreeSql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnetcore%2FFreeSql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnetcore%2FFreeSql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnetcore%2FFreeSql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotnetcore","download_url":"https://codeload.github.com/dotnetcore/FreeSql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252721052,"owners_count":21793746,"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":["access","clickhouse","codefirst","dameng","duckdb","firebird","gbase","hacktoberfest","highgo","kingbase","mysql","odbc","oracle","orm","postgresql","questdb","shentongdata","sqlite","sqlserver","xugu"],"created_at":"2024-09-24T18:51:58.896Z","updated_at":"2025-05-06T16:21:11.430Z","avatar_url":"https://github.com/dotnetcore.png","language":"C#","readme":"\u003ch1 align=\"center\"\u003e 🦄 FreeSql, The First AOT ORM!\u003c/h1\u003e\u003cdiv align=\"center\"\u003e\n\nFreeSql is a powerful O/RM component, supports .NET Core 2.1+, .NET Framework 4.0+, Xamarin, And AOT.\n\n[![Member project of .NET Core Community](https://img.shields.io/badge/member%20project%20of-NCC-9e20c9.svg)](https://github.com/dotnetcore) \n[![nuget](https://img.shields.io/nuget/v/FreeSql.svg?style=flat-square)](https://www.nuget.org/packages/FreeSql) \n[![stats](https://img.shields.io/nuget/dt/FreeSql.svg?style=flat-square)](https://www.nuget.org/stats/packages/FreeSql?groupby=Version) \n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/dotnetcore/FreeSql/master/LICENSE.txt)\n\n\u003cp\u003e\n    \u003cspan\u003eEnglish\u003c/span\u003e |  \n    \u003ca href=\"README.zh-CN.md\"\u003e中文\u003c/a\u003e\n\u003c/p\u003e\n\n\u003c/div\u003e\n\n- 🛠 Support CodeFirst data migration.\n- 💻 Support DbFirst import entity class from database, or use [Generation Tool](https://github.com/dotnetcore/FreeSql/wiki/DbFirst).\n- ⛳ Support advanced type mapping, such as PostgreSQL array type, etc.\n- 🌲 Support expression functions, and customizable analysis.\n- 🏁 Support one-to-many and many-to-many navigation properties, include and lazy loading.\n- 📃 Support Read/Write separation, Splitting Table/Database, Global filters, Optimistic and pessimistic locker.\n- 🌳 Support MySql/SqlServer/PostgreSQL/Oracle/Sqlite/Firebird/达梦/人大金仓/南大通用/虚谷/神舟通用/翰高/ClickHouse/DuckDB/TDengine/QuestDB/MsAccess, etc.\n\nQQ Groups：**561616019(available)**、4336577(full)、8578575(full)、52508226(full)\n\n## 📚 Documentation\n\n| |\n| - |\n| [Get started](https://github.com/dotnetcore/FreeSql/wiki/Getting-Started)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[Select](https://github.com/dotnetcore/FreeSql/wiki/Query-Data)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[Update](https://github.com/dotnetcore/FreeSql/wiki/Update-Data)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[Insert](https://github.com/dotnetcore/FreeSql/wiki/Insert-Data)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[Delete](https://github.com/dotnetcore/FreeSql/wiki/Delete-Data)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[FAQ](https://github.com/dotnetcore/FreeSql/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)\u0026nbsp;\u0026nbsp;|\n| [Expression](https://github.com/dotnetcore/FreeSql/wiki/%e8%a1%a8%e8%be%be%e5%bc%8f%e5%87%bd%e6%95%b0)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[CodeFirst](https://github.com/dotnetcore/FreeSql/wiki/CodeFirst)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[DbFirst](https://github.com/2881099/FreeSql/wiki/DbFirst)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[Filters](https://github.com/dotnetcore/FreeSql/wiki/%e8%bf%87%e6%bb%a4%e5%99%a8)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[AOP](https://github.com/2881099/FreeSql/wiki/AOP)\u0026nbsp;\u0026nbsp;|\n| [Repository](https://github.com/dotnetcore/FreeSql/wiki/Repository-layer)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[UnitOfWork](https://github.com/dotnetcore/FreeSql/wiki/Unit-of-Work)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[Dynamic Operations](https://github.com/dotnetcore/FreeSql/wiki/%E5%8A%A8%E6%80%81%E6%93%8D%E4%BD%9C)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[ADO](https://github.com/2881099/FreeSql/wiki/ADO)\u0026nbsp;\u0026nbsp;|\n| [Read/Write](https://github.com/dotnetcore/FreeSql/wiki/%e8%af%bb%e5%86%99%e5%88%86%e7%a6%bb)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[Splitting Table](https://github.com/dotnetcore/FreeSql/wiki/%e5%88%86%e8%a1%a8%e5%88%86%e5%ba%93)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[Hide tech](https://github.com/dotnetcore/FreeSql/wiki/%E9%AA%9A%E6%93%8D%E4%BD%9C)\u0026nbsp;\u0026nbsp;\\|\u0026nbsp;\u0026nbsp;[*Update Notes*](https://github.com/dotnetcore/FreeSql/wiki/%e6%9b%b4%e6%96%b0%e6%97%a5%e5%bf%97)\u0026nbsp;\u0026nbsp;|\n\n\u003e Please select a development mode:\n\n- Use FreeSql, keep the original usage.\n- Use [FreeSql.DbContext](https://github.com/dotnetcore/FreeSql/wiki/Repository), Repository + UnitOfWork.\n- Use [FreeSql.BaseEntity](https://github.com/dotnetcore/FreeSql/tree/master/Examples/base_entity), Simple mode.\n\n\u003e Some open source projects that use FreeSql:\n\n- [Zhontai.net Management System](https://github.com/zhontai/Admin.Core)\n- [A simple CMS implemented by .NET8](https://github.com/luoyunchong/lin-cms-dotnetcore)\n- [AIBPM workflow](https://github.com/leooneone/aibpm.plus)\n- [NetAdmin A rapid development framework based on C#12/.NET9 and FreeSql](https://github.com/nsnail/NetAdmin)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/dotnetcore/FreeSql/raw/master/functions13.png\"/\u003e\n\u003c/p\u003e\n\n## 🚀 Quick start\n\n\u003e dotnet add package FreeSql.Provider.Sqlite\n\n```csharp\nstatic IFreeSql fsql = new FreeSql.FreeSqlBuilder()\n  .UseConnectionString(FreeSql.DataType.Sqlite, @\"Data Source=document.db\")\n  .UseAutoSyncStructure(true) //automatically synchronize the entity structure to the database\n  .Build(); //be sure to define as singleton mode\n\nclass Song {\n  [Column(IsIdentity = true)]\n  public int Id { get; set; }\n  public string Title { get; set; }\n  public string Url { get; set; }\n  public DateTime CreateTime { get; set; }\n  \n  public ICollection\u003cTag\u003e Tags { get; set; }\n}\nclass Song_tag {\n  public int Song_id { get; set; }\n  public Song Song { get; set; }\n  \n  public int Tag_id { get; set; }\n  public Tag Tag { get; set; }\n}\nclass Tag {\n  [Column(IsIdentity = true)]\n  public int Id { get; set; }\n  public string Name { get; set; }\n  \n  public int? Parent_id { get; set; }\n  public Tag Parent { get; set; }\n  \n  public ICollection\u003cSong\u003e Songs { get; set; }\n  public ICollection\u003cTag\u003e Tags { get; set; }\n}\n```\n\n### 🔎 Query\n```csharp\n//OneToOne、ManyToOne\nfsql.Select\u003cTag\u003e().Where(a =\u003e a.Parent.Parent.Name == \"English\").ToList();\n\n//OneToMany\nfsql.Select\u003cTag\u003e().IncludeMany(a =\u003e a.Tags, then =\u003e then.Where(sub =\u003e sub.Name == \"foo\")).ToList();\n\n//ManyToMany\nfsql.Select\u003cSong\u003e()\n  .IncludeMany(a =\u003e a.Tags, then =\u003e then.Where(sub =\u003e sub.Name == \"foo\"))\n  .Where(s =\u003e s.Tags.Any(t =\u003e t.Name == \"Chinese\"))\n  .ToList();\n\n//Other\nfsql.Select\u003cYourType\u003e()\n  .Where(a =\u003e a.IsDelete == 0)\n  .WhereIf(keyword != null, a =\u003e a.UserName.Contains(keyword))\n  .WhereIf(role_id \u003e 0, a =\u003e a.RoleId == role_id)\n  .Where(a =\u003e a.Nodes.Any(t =\u003e t.Parent.Id == t.UserId))\n  .Count(out var total)\n  .Page(page, size)\n  .OrderByDescending(a =\u003e a.Id)\n  .ToList()\n```\n[More..](https://github.com/dotnetcore/FreeSql/wiki/%e6%9f%a5%e8%af%a2)\n\n```csharp\nfsql.Select\u003cSong\u003e().Where(a =\u003e new[] { 1, 2, 3 }.Contains(a.Id)).ToList();\n\nfsql.Select\u003cSong\u003e().Where(a =\u003e a.CreateTime.Date == DateTime.Today).ToList();\n\nfsql.Select\u003cSong\u003e().OrderBy(a =\u003e Guid.NewGuid()).Limit(10).ToList();\n\nfsql.Select\u003cSong\u003e().ToList(a =\u003e new\n{\n    a.Id,\n    Tags = fsql.Select\u003cTag\u003e().ToList(),\n    SongTags = fsql.Select\u003cSongTag\u003e().Where(b =\u003e b.TopicId == a.Id).ToList()\n});\n```\n[More..](https://github.com/dotnetcore/FreeSql/wiki/%e8%a1%a8%e8%be%be%e5%bc%8f%e5%87%bd%e6%95%b0) \n\n### 🚁 Repository\n\n\u003e dotnet add package FreeSql.Repository\n\n```csharp\n[Transactional]\npublic void Add() {\n  var repo = ioc.GetService\u003cBaseRepository\u003cTag\u003e\u003e();\n  repo.DbContextOptions.EnableCascadeSave = true;\n\n  var item = new Tag {\n    Name = \"testaddsublist\",\n    Tags = new[] {\n      new Tag { Name = \"sub1\" },\n      new Tag { Name = \"sub2\" }\n    }\n  };\n  repo.Insert(item);\n}\n```\n\nReference: [Use `TransactionalAttribute` and `UnitOfWorkManager` in ASP.NET Core to Achieve the *Multiple Transaction Propagation*](https://github.com/dotnetcore/FreeSql/issues/289).\n\n## 💪 Performance\n\nFreeSql Query \u0026 Dapper Query\n\n```shell\nElapsed: 00:00:00.6733199; Query Entity Counts: 131072; ORM: Dapper\n\nElapsed: 00:00:00.4554230; Query Tuple Counts: 131072; ORM: Dapper\n\nElapsed: 00:00:00.6846146; Query Dynamic Counts: 131072; ORM: Dapper\n\nElapsed: 00:00:00.6818111; Query Entity Counts: 131072; ORM: FreeSql*\n\nElapsed: 00:00:00.6060042; Query Tuple Counts: 131072; ORM: FreeSql*\n\nElapsed: 00:00:00.4211323; Query ToList\u003cTuple\u003e Counts: 131072; ORM: FreeSql*\n\nElapsed: 00:00:01.0236285; Query Dynamic Counts: 131072; ORM: FreeSql*\n```\n\nFreeSql ToList \u0026 Dapper Query\n\n```shell\nElapsed: 00:00:00.6707125; ToList Entity Counts: 131072; ORM: FreeSql*\n\nElapsed: 00:00:00.6495301; Query Entity Counts: 131072; ORM: Dapper\n```\n\n[More..](https://github.com/dotnetcore/FreeSql/wiki/%e6%80%a7%e8%83%bd)\n\n## 👯 Contributors\n\n\u003ca href=\"https://contributors-img.web.app/image?repo=dotnetcore/FreeSql\"\u003e\n  \u003cimg src=\"https://contributors-img.web.app/image?repo=dotnetcore/FreeSql\" /\u003e\n\u003c/a\u003e\n\nAnd other friends who made important suggestions for this project, they include:\n\n[systemhejiyong](https://github.com/systemhejiyong), \n[LambertW](https://github.com/LambertW), \n[mypeng1985](https://github.com/mypeng1985), \n[stulzq](https://github.com/stulzq), \n[movingsam](https://github.com/movingsam), \n[ALer-R](https://github.com/ALer-R), \n[zouql](https://github.com/zouql), \n深圳|凉茶, \n[densen2014](https://github.com/densen2014), \n[LiaoLiaoWuJu](https://github.com/LiaoLiaoWuJu), \n[hd2y](https://github.com/hd2y), \n[tky753](https://github.com/tky753), \n[feijie999](https://github.com/feijie999), \nconstantine, \n[JohnZhou2020](https://github.com/JohnZhou2020), \n[mafeng8](https://github.com/mafeng8), \n[VicBilibily](https://github.com/VicBilibily), \n[Soar](https://github.com/sgf),\n[quzhen91](https://github.com/quzhen91),\nhomejun,\n[d4ilys](https://github.com/d4ilys) etc.\n\n## 💕 Donation\n\nL*y 58元、花花 88元、麦兜很乖 50元、网络来者 2000元、John 99.99元、alex 666元、bacongao 36元、无名 100元、Eternity 188元、无名 10元、⌒.Helper~..oO 66元、习惯与被习惯 100元、无名 100元、蔡易喋 88.88元、中讯科技 1000元、Good Good Work 24元、Nothing 100元、兰州天擎赵 500元、哈利路亚 300元、\n无名 100元、蛰伏 99.99元、TCYM 66.66元、MOTA 5元、LDZXG 30元、Near 30元、建爽 66元、无名 200元、LambertWu 100元、无名 18.88元、乌龙 50元、无名 100元、陳怼怼 66.66元、陳怼怼 66.66元、丁淮 100元、李伟坚-Excel催化剂 100元、白狐 6.66元、她微笑的脸y 30元、Eternity²º²¹ 588元、夜归柴门 88元、蔡易喋 666.66元、\n*礼 10元、litrpa 88元、Alax CHOW 200元、Daily 66元、k\\*t 66元、蓝 100元、*菜 10元、生命如歌 1000元、山鸡 88元、平凡 100元、大树 1000元、软软的毛毛虫 66.66元、问卷星 2000元、与你无关 5000元\n\n\u003e Thank you for your donation\n\n- [Alipay](https://www.cnblogs.com/FreeSql/gallery/image/338860.html)\n\n- [WeChat](https://www.cnblogs.com/FreeSql/gallery/image/338859.html)\n\n## 🗄 License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnetcore%2Ffreesql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotnetcore%2Ffreesql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnetcore%2Ffreesql/lists"}