{"id":28328465,"url":"https://github.com/nosratifarhad/mediatr","last_synced_at":"2026-05-01T06:31:58.023Z","repository":{"id":163239161,"uuid":"616099944","full_name":"nosratifarhad/MediatR","owner":"nosratifarhad","description":"Separating commands and queries in User Mediator In .Net 6","archived":false,"fork":false,"pushed_at":"2023-12-01T10:03:29.000Z","size":129,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-24T08:43:06.113Z","etag":null,"topics":["command","cqrs","dotnet","dotnet-core","dotnetcore","mediatr","query"],"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/nosratifarhad.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}},"created_at":"2023-03-19T15:59:58.000Z","updated_at":"2024-09-23T06:10:22.000Z","dependencies_parsed_at":"2023-12-01T11:55:39.749Z","dependency_job_id":null,"html_url":"https://github.com/nosratifarhad/MediatR","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nosratifarhad/MediatR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FMediatR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FMediatR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FMediatR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FMediatR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nosratifarhad","download_url":"https://codeload.github.com/nosratifarhad/MediatR/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FMediatR/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32487300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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":["command","cqrs","dotnet","dotnet-core","dotnetcore","mediatr","query"],"created_at":"2025-05-26T06:17:06.304Z","updated_at":"2026-05-01T06:31:58.016Z","avatar_url":"https://github.com/nosratifarhad.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MediatR\n\n## More details about the architecture .\n\n* 1 - Application Folder is Application Layer \n    * In This Layer , Have Command And Queries And Handlers .\n* 2 - Service Folder is Service Layer \n    * For Data Persistence And Use ORM (Entity FrameWork). \n\n### first You need to install the following packages :\n\n```\nNuGet\\Install-Package MediatR.Extensions.Microsoft.DependencyInjection \n```\n### You must pass the \"Assembly\" when adding the MediatR service to project , like this\n\n```csharp\n//services.AddMediatR(Assembly.GetExecutingAssembly());\nservices.AddMediatR(typeof(Program).Assembly);\n```\n### And the Final level for use \"MediatR\" : \n* Go To Application Folder (Layer) And Create Command Or Query and Use down Code in Application Layer .\n* You should use \"IRequest\" for command and query requests , like this :\n\n### Sample Command And CommandHandler\n\n```csharp\n\n// Use IRequest In Command Model\npublic class CreateProductCommand : IRequest\n{\n  public string ProductTitle { get; set; }\n\n  public string ProductName { get; set; }\n}\n    \n// Use IRequestHandler In Command Handler\npublic class CreateProductCommandHandler : IRequestHandler\u003cCreateProductCommand\u003e\n{\n   public async Task\u003cUnit\u003e Handle(CreateProductCommand request, CancellationToken cancellationToken)\n   {\n      var createProductDto = GenereateCreateProductDtoFromaCommand(request);\n\n      await _productService.CreateProduct(createProductDto).ConfigureAwait(false);\n\n      return Unit.Value;\n   }\n}\n\n```\n### Sample Query And QueryHandler\n\n```csharp\n\n// Use IRequest In Query Model \npublic class GetProductQuery : IRequest\u003cIEnumerable\u003cProductVM\u003e\u003e\n{\n  public int ProductId { get; set; }\n}\n\n// Use IRequest In Query Handler\npublic class GetProductQueryHandler : IRequestHandler\u003cGetProductQuery, IEnumerable\u003cProductVM\u003e\u003e\n{\n     public async Task\u003cIEnumerable\u003cProductVM\u003e\u003e Handle(GetProductQuery request, CancellationToken cancellationToken)\n     {\n         var productVMList = await _productService.GetProduct().ConfigureAwait(false);\n\n         return productVMList;\n     }\n}\n\n```\n![My Remote Image](https://github.com/nosratifarhad/MediatR/blob/main/imgs/Annotation.jpg)\n![My Remote Image](https://github.com/nosratifarhad/MediatR/blob/main/imgs/Annotation1.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnosratifarhad%2Fmediatr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnosratifarhad%2Fmediatr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnosratifarhad%2Fmediatr/lists"}