{"id":29804259,"url":"https://github.com/swtanggara/intoitif","last_synced_at":"2025-07-28T12:17:43.069Z","repository":{"id":38326186,"uuid":"153000546","full_name":"swtanggara/IntoItIf","owner":"swtanggara","description":"It's kinda Unit of Work, Repository things, done intuitively in EF AND EF Core.","archived":false,"fork":false,"pushed_at":"2023-03-04T01:02:04.000Z","size":1595,"stargazers_count":10,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-25T22:50:56.116Z","etag":null,"topics":["csharp","interceptor-service","repository-pattern","unit-of-work"],"latest_commit_sha":null,"homepage":"https://swtanggara.github.io/IntoItIf/","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/swtanggara.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}},"created_at":"2018-10-14T17:32:31.000Z","updated_at":"2024-10-28T08:39:42.000Z","dependencies_parsed_at":"2024-06-21T14:19:38.673Z","dependency_job_id":"7f42bf94-3ef5-41f8-b830-60c54257fc2b","html_url":"https://github.com/swtanggara/IntoItIf","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/swtanggara/IntoItIf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swtanggara%2FIntoItIf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swtanggara%2FIntoItIf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swtanggara%2FIntoItIf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swtanggara%2FIntoItIf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swtanggara","download_url":"https://codeload.github.com/swtanggara/IntoItIf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swtanggara%2FIntoItIf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267514963,"owners_count":24100030,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["csharp","interceptor-service","repository-pattern","unit-of-work"],"created_at":"2025-07-28T12:17:38.251Z","updated_at":"2025-07-28T12:17:43.029Z","avatar_url":"https://github.com/swtanggara.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"IntoItIf\n===============\n[![AppVeyor](https://img.shields.io/appveyor/ci/swtanggara/IntoItIf.svg)](https://ci.appveyor.com/project/swtanggara/intoitif)\n[![Github All Releases](https://img.shields.io/github/downloads/swtanggara/IntoItIf/total.svg)](https://github.com/swtanggara/IntoItIf/releases)\n[![Github Releases](https://img.shields.io/github/downloads/swtanggara/IntoItIf/latest/total.svg)](https://github.com/swtanggara/IntoItIf/releases/latest)\n[![GitHub](https://img.shields.io/github/license/swtanggara/IntoItIf.svg)](https://github.com/swtanggara/IntoItIf/blob/master/LICENSE)\n\nIt's kinda Unit of Work, Repository things, done intuitively in EF **AND** EF Core.\n\n| Project | NuGet | Frameworks | Dependencies | NuGet Downloads |\n| ------- | ----- | ---------- | ------------ | --------------- |\n| IntoItIf.Dsl | [![NuGet](https://img.shields.io/nuget/v/IntoItIf.Dsl.svg)](https://www.nuget.org/packages/IntoItIf.Dsl/) | net471 and up, netstandard20 and up | IntoItIf.Dal | [![NuGet](https://img.shields.io/nuget/dt/IntoItIf.Dsl.svg)](https://www.nuget.org/packages/IntoItIf.Dsl/) |\n| IntoItIf.Dal | [![NuGet](https://img.shields.io/nuget/v/IntoItIf.Dal.svg)](https://www.nuget.org/packages/IntoItIf.Dal/) | net471 and up, netstandard20 and up | IntoItIf.Core | [![NuGet](https://img.shields.io/nuget/dt/IntoItIf.Dal.svg)](https://www.nuget.org/packages/IntoItIf.Dal/) |\n| IntoItIf.Core | [![NuGet](https://img.shields.io/nuget/v/IntoItIf.Core.svg)](https://www.nuget.org/packages/IntoItIf.Core/) | net471 and up, netstandard20 and up | None | [![NuGet](https://img.shields.io/nuget/dt/IntoItIf.Core.svg)](https://www.nuget.org/packages/IntoItIf.Core/) |\n| IntoItIf.Dsl.AutoMapper | [![NuGet](https://img.shields.io/nuget/v/IntoItIf.Dsl.AutoMapper.svg)](https://www.nuget.org/packages/IntoItIf.Dsl.AutoMapper/) | net471 and up, netstandard20 and up | IntoItIf.Dsl | [![NuGet](https://img.shields.io/nuget/dt/IntoItIf.Dsl.AutoMapper.svg)](https://www.nuget.org/packages/IntoItIf.Dsl.AutoMapper/) |\n| IntoItIf.Dsl.BatMap | [![NuGet](https://img.shields.io/nuget/v/IntoItIf.Dsl.BatMap.svg)](https://www.nuget.org/packages/IntoItIf.Dsl.BatMap/) | net471 and up, netstandard20 and up | IntoItIf.Dsl | [![NuGet](https://img.shields.io/nuget/dt/IntoItIf.Dsl.BatMap.svg)](https://www.nuget.org/packages/IntoItIf.Dsl.BatMap/) |\n| IntoItIf.Dsl.Mapster | [![NuGet](https://img.shields.io/nuget/v/IntoItIf.Dsl.Mapster.svg)](https://www.nuget.org/packages/IntoItIf.Dsl.Mapster/) | net471 and up, netstandard20 and up | IntoItIf.Dsl | [![NuGet](https://img.shields.io/nuget/dt/IntoItIf.Dsl.Mapster.svg)](https://www.nuget.org/packages/IntoItIf.Dsl.Mapster/) |\n\n### Setting it Up\nYou must setting up your `DbContext` class first, either by inheriting `EfCoreDbContext` (EF Core) or `EfDbContext` (EF):\n\n```c#\npublic class MyDbContext : EfCoreDbContext // Inherit from EfDbContext if you are using EF6 or above\n{\n   public DbSet\u003cMyEntity\u003e Entities { get; set; }\n}\n```\n\nwhere `MyEntity` must inherit from `IEntity` or from base templating class `BaseEntity\u003cTEntity\u003e`:\n\n```c#\npublic class MyEntity : BaseEntity\u003cMyEntity\u003e\n{\n   [Key]\n   public int Id { get; set; }\n   \n   public string Name { get; set; }\n}\n```\n\nnext, define your `MyDto` class for mapping from `MyEntity`. This `MyDto` class must inherit from `IDto`, or better from `BaseDto\u003cTDto, TValidator\u003e` class:\n\n```c#\npublic class MyDto: BaseDto\u003cMyDto, MyDtoFluentValidator\u003e\n{\n   public int Id { get; set; }\n   public string Name { get; set; }\n}\n```\n\ndon't forget to define you `MyDto` validator class, by inheriting `BaseFluentValidator\u003cT\u003e` (using [`FluentValidator`](https://github.com/JeremySkinner/FluentValidation)) or `BaseValitValidator\u003cT\u003e` (using [`Valit`](https://github.com/valit-stack/Valit)):\n\n```c#\npublic class MyDtoFluentValidator: BaseFluentValidator\u003cMyDto\u003e\n{\n   public MyDtoFluentValidator()\n   {\n      RuleFor(x =\u003e x.Id).NotEmpty();\n      RuleFor(x =\u003e x.Name).NotEmpty();\n   }\n}\n```\n\n(`BaseValitValidator\u003cT\u003e` version):\n\n```c#\npublic class MyDtoValitValidator : BaseValitValidator\u003cMyDto\u003e\n{\n   public MyDtoValitValitator()\n   {\n      Valitator = ValitRules\u003cMyDto\u003e.Create()\n        .Ensure(x =\u003e x.Id, x =\u003e x.IsNonZero())\n        .Ensure(x =\u003e x.Name, x =\u003e x.Required())\n        .CreateValitator();\n   }\n   \n   protected override IValitator\u003cMyDto\u003e Valitator { get; }\n}\n```\n\nnext, create you `IMapperProfile` derived class to maps `MyEntity` to `MyDto` and vice-versa:\n\n```c#\npublic class MyMapperProfile : IMapperProfile\n{\n   public Option\u003c(Type Source, Type Destination)\u003e[] GetBinds()\n   {\n      return new Option\u003c(Type Source, Type Destination)\u003e[]\n      {\n         (typeof(MyEntity), typeof(MyDto)),\n         (typeof(MyDto), typeof(MyEntity)),\n      };\n   }\n}\n```\n\nAnd, lastly, at your *startup* class, inject the `IMapperService` like so:\n\n```c#\n// Use AutoMapper if you want to support Value-Object pattern\nvar mapperSvc = new AutoMapperService(); // Choose between AutoMapperService, BatMapMapperService, or MapsterMapperService\nmapperSvc.Initialize\u003cIMapperProfile\u003e(new MyMapperProfile());\nDslInjecterGetter.SetBaseMapperService(mapperSvc);\nvar uow = new EfCoreUnitOfWork(new MyDbContext()); // Or use EfUnitOfWork, if you are using EF6 or above.\nDslInjecterGetter.SetBaseUnitOfWork(uow);\n```\n\n### Usage\nIt's quite daunting to setting it up huh? But wait, this is how you can utilize my charming library:\n\n```c#\nOption\u003cCancellationToken\u003e ctok = CancellationToken.None;\nvar dto = new MyDto();\n\nvar createResult = Create\u003cMyEntity, MyDto, MyCreateInterceptor\u003e.Handle(dto, ctok);\nvar deleteResult = Delete\u003cMyEntity, MyDto, MyDeleteInterceptor\u003e.Handle(dto, ctok);\nvar readLookupResult = ReadLookup\u003cMyEntity, MyDto, MyReadLookupInterceptor\u003e.Handle(false, ctok);\nvar readOneResult = ReadOne\u003cMyEntity, MyDto, MyReadOneInterceptor\u003e.Handle(dto, ctok);\nvar readPagedResult = ReadPaged\u003cMyEntity, MyDto, MyReadPagedInterceptor\u003e.Handle(1, 1, null, \"Bla\", ctok);\nvar updateResult = Update\u003cMyEntity, MyDto, MyUpdateInterceptor\u003e.Handle(dto, ctok);\n```\n\nAnd if you need transactional DB processing, you would do it like this:\n\n```c#\nusing (var trx = uow.GetDbTransaction\u003cMyDbContext\u003e())\n{\n   try\n   {\n      var createResult = Create\u003cMyEntity, MyDto, MyCreateInterceptor\u003e.Handle(dto, ctok);\n      var deleteResult = Delete\u003cMyEntity, MyDto, MyDeleteInterceptor\u003e.Handle(dto, ctok);\n      var readLookupResult = ReadLookup\u003cMyEntity, MyDto, MyReadLookupInterceptor\u003e.Handle(false, ctok);\n      var readOneResult = ReadOne\u003cMyEntity, MyDto, MyReadOneInterceptor\u003e.Handle(dto, ctok);\n      var readPagedResult = ReadPaged\u003cMyEntity, MyDto, MyReadPagedInterceptor\u003e.Handle(1, 1, null, \"Bla\", ctok);\n      var updateResult = Update\u003cMyEntity, MyDto, MyUpdateInterceptor\u003e.Handle(dto, ctok);\n      trx.Commit();\n   }\n   catch (Exception ex)\n   {\n      trx.Rollback();\n   }\n}\n```\n\nYes, of course, you will ask: what `MyCreateInterceptor`, `MyDeleteInterceptor`, `MyReadLookupInterceptor`, \n`MyReadOneInterceptor`, `MyReadOneInterceptor`, `MyReadPagedInterceptor`, and `MyUpdateInterceptor` are all about. It's your task to find what they are....\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswtanggara%2Fintoitif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswtanggara%2Fintoitif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswtanggara%2Fintoitif/lists"}