{"id":13490530,"url":"https://github.com/zzzprojects/EntityFramework.Extended","last_synced_at":"2025-03-28T06:31:33.827Z","repository":{"id":1856028,"uuid":"2780842","full_name":"zzzprojects/EntityFramework.Extended","owner":"zzzprojects","description":"Add-on feature for Entity Framework","archived":false,"fork":false,"pushed_at":"2024-03-20T20:51:44.000Z","size":5160,"stargazers_count":1338,"open_issues_count":163,"forks_count":389,"subscribers_count":151,"default_branch":"master","last_synced_at":"2025-03-24T18:11:16.701Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"micahmcfarland/ratchet","license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zzzprojects.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"License.txt","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},"funding":{"github":["zzzprojects"],"custom":["https://zzzprojects.com/contribute"]}},"created_at":"2011-11-15T15:04:43.000Z","updated_at":"2025-02-26T02:40:55.000Z","dependencies_parsed_at":"2025-03-01T09:11:14.703Z","dependency_job_id":"ce6b9e7d-c498-47ca-b526-777bf8e45654","html_url":"https://github.com/zzzprojects/EntityFramework.Extended","commit_stats":null,"previous_names":["loresoft/entityframework.extended"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzzprojects%2FEntityFramework.Extended","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzzprojects%2FEntityFramework.Extended/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzzprojects%2FEntityFramework.Extended/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzzprojects%2FEntityFramework.Extended/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zzzprojects","download_url":"https://codeload.github.com/zzzprojects/EntityFramework.Extended/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245984558,"owners_count":20704792,"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-31T19:00:48.063Z","updated_at":"2025-03-28T06:31:29.966Z","avatar_url":"https://github.com/zzzprojects.png","language":"C#","funding_links":["https://github.com/sponsors/zzzprojects","https://zzzprojects.com/contribute"],"categories":["Unsupported Packages","C\\#","C#"],"sub_categories":[],"readme":"## Library Powered By\n\nThis library is powered by [Entity Framework Extensions](https://entityframework-extensions.net/?z=github\u0026y=entityframework-plus)\n\n\u003ca href=\"https://entityframework-extensions.net/?z=github\u0026y=entityframework-plus\"\u003e\n\u003ckbd\u003e\n\u003cimg src=\"https://zzzprojects.github.io/images/logo/entityframework-extensions-pub.jpg\" alt=\"Entity Framework Extensions\" /\u003e\n\u003c/kbd\u003e\n\u003c/a\u003e\n\n---\n\n**IMPORTANT:** This library is no longer supported since 2015. \n\nWe highly recommend you to move to:\n- [Entity Framework Extensions](https://entityframework-extensions.net/?z=ef-extended) for pro features\n- [Entity Framework Plus](https://entityframework-plus.net/?z=ef-extended) for free features\n\n### Entity Framework Extensions\nWebsite: [https://entityframework-extensions.net/](https://entityframework-extensions.net/?z=ef-extended)\n\nPaid library to dramatically improve Entity Framework performance:\n\n- BulkSaveChanges\n- BulkInsert\n- BulkUpdate\n- BulkDelete\n- BulkMerge\n- BulkSynchronize\n\n### Entity Framework Plus\nWebsite: [https://entityframework-plus.net/](https://entityframework-plus.net/?z=ef-extended)\n\nFree \u0026 Open source library that support following features:\n\n- Audit\n- Batch Operations\n    - Batch Delete\n    - Batch Update\n- Query\n    - Query Cache \n    - Query Deferred\n    - Query Filter\n    - Query Future\n    - Query IncludeFilter\n    - Query IncludeOptimized\n\n# What's Entity Framework Extended? \n\n## Download\n\nThe Entity Framework Extended library is available on nuget.org via package name `EntityFramework.Extended`.\n\nTo install EntityFramework.Extended, run the following command in the Package Manager Console.\n\n    PM\u003e Install-Package EntityFramework.Extended\n    \n## Features\n\n- [Batch Update and Delete](https://entityframework-plus.net/ef-core-batch-update)\n- [Future Queries](https://entityframework-plus.net/ef-core-query-future)\n- [Query Result Cache](https://entityframework-plus.net/ef-core-query-cache)\n- [Audit Log](https://entityframework-plus.net/ef-core-audit)\n \n### Batch Update and Delete\n\nThe Entity Framework's current limitation is that you have first to retrieve it into memory to update or delete an entity. Now in most scenarios, this is just fine. There are, however, some scenarios where performance would suffer. Also, the object must be retrieved for single deletes before it can be deleted, requiring two calls to the database. Batch update and delete eliminate the need to retrieve and load an entity before modifying it.\n\n**Deleting**\n    \n    //delete all users where FirstName matches\n    context.Users\n        .Where(u =\u003e u.FirstName == \"firstname\")\n        .Delete();\n\n**Update**\n    \n    //update all tasks with status of 1 to status of 2\n    context.Tasks\n        .Where(t =\u003e t.StatusId == 1)\n        .Update(t =\u003e new Task { StatusId = 2 });\n    \n    //example of using an IQueryable as the filter for the update\n    var users = context.Users.Where(u =\u003e u.FirstName == \"firstname\");\n    context.Users.Update(users, u =\u003e new User {FirstName = \"newfirstname\"});\n\n### Future Queries\n\nBuild up a list of queries for the data that you need, and the first time any of the results are accessed, all the data will retrieved in one round trip to the database server. Reducing the number of trips to the database is a great. Using this feature is as simple as appending `.Future()` to the end of your queries to use the Future Queries. \n\nFuture queries are created with the following extension methods:\n\n- Future()\n- FutureFirstOrDefault()\n- FutureCount()\n\nSample\n\n    // build up queries\n    var q1 = db.Users\n        .Where(t =\u003e t.EmailAddress == \"one@test.com\")\n        .Future();\n    \n    var q2 = db.Tasks\n        .Where(t =\u003e t.Summary == \"Test\")\n        .Future();\n    \n    // this triggers the loading of all the future queries\n    var users = q1.ToList();\n\nIn the example above, there are two queries built up. As soon as one of the queries is enumerated, it triggers the batch load of both queries.\n     \n    // base query\n    var q = db.Tasks.Where(t =\u003e t.Priority == 2);\n    // get total count\n    var q1 = q.FutureCount();\n    // get page\n    var q2 = q.Skip(pageIndex).Take(pageSize).Future();\n    \n    // triggers execute as a batch\n    int total = q1.Value;\n    var tasks = q2.ToList();\n    \nIn this example, we have a common scenario where you want to page a list of tasks. For the GUI to set up the paging control, you need a total count. With Future, we can batch together the queries to get all the data in one database call.\n\nFuture queries work by creating the appropriate IFutureQuery object that keeps the IQuerable. The IFutureQuery object is then stored in IFutureContext.FutureQueries list. Then, when one of the IFutureQuery objects is enumerated, it calls back to IFutureContext.ExecuteFutureQueries() via the LoadAction delegate. ExecuteFutureQueries builds a batch query from all the stored IFutureQuery objects. Finally, all the IFutureQuery objects are updated with the results from the query.\n\n### Query Result Cache\n\nTo cache query results, use the `FromCache` extension method. Below is a caching query result. Construct the LINQ query as you normally would, then append the `FromCache` extension.\n     \n    //query is cached using the default settings\n    var tasks = db.Tasks\n        .Where(t =\u003e t.CompleteDate == null)\n        .FromCache();\n \n    //query result is now cached 300 seconds\n    var tasks = db.Tasks\n        .Where(t =\u003e t.AssignedId == myUserId \u0026\u0026 t.CompleteDate == null)\n        .FromCache(CachePolicy.WithDurationExpiration(TimeSpan.FromSeconds(300)));\n        \nThe Query Result Cache also supports tagging the cache so you can expire common cache entries by calling `Expire` on a cache tag.\n\n    // cache assigned tasks\n    var tasks = db.Tasks\n        .Where(t =\u003e t.AssignedId == myUserId \u0026\u0026 t.CompleteDate == null)\n        .FromCache(tags: new[] { \"Task\", \"Assigned-Task-\" + myUserId  });\n\n    // some update happened to Task, expire Task tag\n    CacheManager.Current.Expire(\"Task\");\n    \nThe `CacheManager` has support for providers.  The default provider uses `MemoryCache` to store the cache entries.  To create a custom provider, implement `ICacheProvider`. The custom provider will then need to be registered in the `Locator` container.\n\n    // Replace cache provider with Memcached provider\n    Locator.Current.Register\u003cICacheProvider\u003e(() =\u003e new MemcachedProvider());\n\n### Audit Log\n\nThe Audit Log feature will capture the changes to entities anytime they are submitted to the database. The Audit Log captures only the changed entities and only the changed properties. The before and after values are recorded. `AuditLogger.LastAudit` is where this information is held and there is a `ToXml()` method that makes it easy to turn the AuditLog into xml for easy storage.\n\nThe AuditLog can be customized via attributes on the entities or via a Fluent Configuration API.\n\nFluent Configuration\n    \n    // config audit when your application is starting up...\n    var auditConfiguration = AuditConfiguration.Default;\n    \n    auditConfiguration.IncludeRelationships = true;\n    auditConfiguration.LoadRelationships = true;\n    auditConfiguration.DefaultAuditable = true;\n    \n    // customize the audit for Task entity\n    auditConfiguration.IsAuditable\u003cTask\u003e()\n        .NotAudited(t =\u003e t.TaskExtended)\n        .FormatWith(t =\u003e t.Status, v =\u003e FormatStatus(v));\n    \n    // set the display member when status is a foreign key\n    auditConfiguration.IsAuditable\u003cStatus\u003e()\n        .DisplayMember(t =\u003e t.Name);\n\nCreate an Audit Log\n\n    var db = new TrackerContext();\n    var audit = db.BeginAudit();\n\n    // make some updates ...\n\n    db.SaveChanges();\n    var log = audit.LastLog;\n\n## Useful links\n\n- [Documentation](https://entityframework.net/ef-extended)\n- [NuGet](https://nuget.org/packages/EntityFramework.Extended)\n- You can also consult several questions on \n[Stack Overflow](https://stackoverflow.com/questions/tagged/entity-framework-extended)\n\n## Contribute\n\nThe best way to contribute is by **spreading the word** about the library:\n\n - Blog it\n - Comment it\n - Star it\n - Share it\n \nA **HUGE THANKS** for your help.\n\n## More Projects\n\n- Projects:\n   - [EntityFramework Extensions](https://entityframework-extensions.net/)\n   - [Dapper Plus](https://dapper-plus.net/)\n   - [C# Eval Expression](https://eval-expression.net/)\n- Learn Websites\n   - [Learn EF Core](https://www.learnentityframeworkcore.com/)\n   - [Learn Dapper](https://www.learndapper.com/)\n- Online Tools:\n   - [.NET Fiddle](https://dotnetfiddle.net/)\n   - [SQL Fiddle](https://sqlfiddle.com/)\n   - [ZZZ Code AI](https://zzzcode.ai/)\n- and much more!\n\nTo view all our free and paid projects, visit our website [ZZZ Projects](https://zzzprojects.com/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzzprojects%2FEntityFramework.Extended","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzzzprojects%2FEntityFramework.Extended","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzzprojects%2FEntityFramework.Extended/lists"}