diff --git a/OfX.sln b/OfX.sln index 6b0087a..ac57cd1 100644 --- a/OfX.sln +++ b/OfX.sln @@ -8,6 +8,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OfX.EntityFrameworkCore", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OfX.Grpc", "src\OfX.Grpc\OfX.Grpc.csproj", "{36F9049C-6A77-4EF7-9CE0-86A22CA36DEA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OfX.Nats", "src\OfX.Nats\OfX.Nats.csproj", "{4E3B4EB4-8A12-41A4-B630-2601414CE0F3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -30,6 +32,10 @@ Global {36F9049C-6A77-4EF7-9CE0-86A22CA36DEA}.Debug|Any CPU.Build.0 = Debug|Any CPU {36F9049C-6A77-4EF7-9CE0-86A22CA36DEA}.Release|Any CPU.ActiveCfg = Release|Any CPU {36F9049C-6A77-4EF7-9CE0-86A22CA36DEA}.Release|Any CPU.Build.0 = Release|Any CPU + {4E3B4EB4-8A12-41A4-B630-2601414CE0F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E3B4EB4-8A12-41A4-B630-2601414CE0F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E3B4EB4-8A12-41A4-B630-2601414CE0F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E3B4EB4-8A12-41A4-B630-2601414CE0F3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution EndGlobalSection diff --git a/src/OfX.EntityFrameworkCore/README.md b/src/OfX.EntityFrameworkCore/README.md index 713be99..c46039e 100644 --- a/src/OfX.EntityFrameworkCore/README.md +++ b/src/OfX.EntityFrameworkCore/README.md @@ -1,6 +1,6 @@ -# OfX.EntityFrameworkCore +# OfX-Nats -OfX.EntityFrameworkCore is an extension package for OfX that integrates with Entity Framework Core to simplify data fetching by leveraging attribute-based data mapping. This extension streamlines data retrieval using EF Core, reducing boilerplate code and improving maintainability. +OfX-Nats is an extension package for OfX that leverages Nats for efficient data transportation. This package provides a high-performance, strongly-typed communication layer for OfX’s Attribute-based Data Mapping, enabling streamlined data retrieval across distributed systems. [Demo Project!](https://github.com/quyvu01/TestOfX-Demo) @@ -8,69 +8,61 @@ OfX.EntityFrameworkCore is an extension package for OfX that integrates with Ent ## Introduction -OfX.EntityFrameworkCore extends the core OfX library by providing seamless integration with Entity Framework Core. This enables developers to automatically map and retrieve data directly from a database, leveraging the power of EF Core along with attribute-based data mapping. - -For example, suppose you have a `UserId` property in your model, and you want to fetch the corresponding `UserName` and `Email` fields from the database. By using OfX.EntityFrameworkCore, you can annotate your model with attributes, and the library will handle data fetching for you. +Nats-based Transport: Implements Nats to handle data communication between services, providing a fast, secure, and scalable solution. --- ## Installation -To install the OfX.EntityFrameworkCore package, use the following NuGet command: +To install the OfX-Nats package, use the following NuGet command: ```bash -dotnet add package OfX-EFCore +dotnet add package OfX-Nats ``` Or via the NuGet Package Manager: ```bash -Install-Package OfX-EFCore +Install-Package OfX-Nats ``` --- ## How to Use -### 1. Register OfX.EntityFrameworkCore +### 1. Register OfX-Nats + +Add OfX-Nats to your service configuration during application startup: -Add OfX.EntityFrameworkCore to your service configuration during application startup: +For Client: ```csharp builder.Services.AddOfXEntityFrameworkCore(cfg => { - cfg.AddAttributesContainNamespaces(typeof(WhereTheAttributeDefined).Assembly); + cfg.AddContractsContainNamespaces(typeof(SomeContractAssemblyMarker).Assembly); cfg.AddHandlersFromNamespaceContaining(); -}) -.AddOfXEFCore(options => -{ - options.AddDbContexts(typeof(TestDbContext)); - options.AddModelConfigurationsFromNamespaceContaining(); -}); -``` + cfg.AddNats(config => config + config.UseNats((context, bus) => + { + bus.Host(host, c => + { + c.Username(userName); + c.Password(password); + }); + bus.ConfigureEndpoints(context); + }); + ); -After installing the package OfX-EFCore, you can use the method `AddDbContexts()`, which takes `DbContext(s)` to executing. - -### 2. Mark the model you want to use with OfXAttribute -Example: - -```csharp -[OfXConfigFor(nameof(Id), nameof(Name))] -public class User -{ - public string Id { get; set; } - public string Name { get; set; } - public string Email { get; set; } -} +}); ``` -That all! Let go to the moon! +That All, enjoy your moment! -Note: Currently, the Id type is supported for primitive type, in the next version. The strongly-type should be supported! -| Package Name | Description | .NET Version | Document | -|----------------------------------------------------------|-------------------------------------------------------------------------------------------------|--------------|---------------------------------------------------------------------------| -| [OfX](https://www.nuget.org/packages/OfX/) | OfX core | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/README.md) | -| [OfX-EFCore](https://www.nuget.org/packages/OfX-EFCore/) | This is the OfX extension package using EntityFramework to fetch data | 8.0, 9.0 | This Document | -| [OfX-gRPC](https://www.nuget.org/packages/OfX-gRPC/) | OfX.gRPC is an extension package for OfX that leverages gRPC for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.Grpc/README.md) | +| Package Name | Description | .NET Version | Document | +|----------------------------------------------------------|-------------------------------------------------------------------------------------------------|--------------|------------------------------------------------------------------------------------------| +| [OfX](https://www.nuget.org/packages/OfX/) | OfX core | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/README.md) | +| [OfX-EFCore](https://www.nuget.org/packages/OfX-EFCore/) | This is the OfX extension package using EntityFramework to fetch data | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.EntityFrameworkCore/README.md) | +| [OfX-gRPC](https://www.nuget.org/packages/OfX-gRPC/) | OfX-gRPC is an extension package for OfX that leverages gRPC for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.Grpc/README.md) | +| [OfX-Nats](https://www.nuget.org/packages/OfX-Nats/) | OfX-Nats is an extension package for OfX that leverages Nats for efficient data transportation. | 8.0, 9.0 | This Document | --- \ No newline at end of file diff --git a/src/OfX.Grpc/README.md b/src/OfX.Grpc/README.md index 40dbfc7..004fd0d 100644 --- a/src/OfX.Grpc/README.md +++ b/src/OfX.Grpc/README.md @@ -1,6 +1,6 @@ -# OfX.gRPC +# OfX-gRPC -OfX.gRPC is an extension package for OfX that leverages gRPC for efficient data transportation. This package provides a high-performance, strongly-typed communication layer for OfX’s Attribute-based Data Mapping, enabling streamlined data retrieval across distributed systems. +OfX-gRPC is an extension package for OfX that leverages gRPC for efficient data transportation. This package provides a high-performance, strongly-typed communication layer for OfX’s Attribute-based Data Mapping, enabling streamlined data retrieval across distributed systems. [Demo Project!](https://github.com/quyvu01/TestOfX-Demo) @@ -14,7 +14,7 @@ gRPC-based Transport: Implements gRPC to handle data communication between servi ## Installation -To install the OfX.EntityFrameworkCore package, use the following NuGet command: +To install the OfX-gRPC package, use the following NuGet command: ```bash dotnet add package OfX-gRPC diff --git a/src/OfX.Nats/OfX.Nats.csproj b/src/OfX.Nats/OfX.Nats.csproj new file mode 100644 index 0000000..615ff9d --- /dev/null +++ b/src/OfX.Nats/OfX.Nats.csproj @@ -0,0 +1,23 @@ + + + + enable + enable + net9.0;net8.0 + default + 3.1.1 + OfX.png + + + + + + + + True + + OfX.png + + + + diff --git a/src/OfX.Nats/README.md b/src/OfX.Nats/README.md new file mode 100644 index 0000000..00c6c39 --- /dev/null +++ b/src/OfX.Nats/README.md @@ -0,0 +1,67 @@ +# OfX-Nats + +OfX-Nats is an extension package for OfX that leverages Nats for efficient data transportation. This package provides a high-performance, strongly-typed communication layer for OfX’s Attribute-based Data Mapping, enabling streamlined data retrieval across distributed systems. + +[Demo Project!](https://github.com/quyvu01/TestOfX-Demo) + +--- + +## Introduction + +Nats-based Transport: Implements Nats to handle data communication between services, providing a fast, secure, and scalable solution. + +--- + +## Installation + +To install the OfX-Nats package, use the following NuGet command: + +```bash +dotnet add package OfX-Nats +``` + +Or via the NuGet Package Manager: + +```bash +Install-Package OfX-Nats +``` + +--- + +## How to Use + +### 1. Register OfX-Nats + +Add OfX-Nats to your service configuration during application startup: + +For Client: + +```csharp +builder.Services.AddOfXEntityFrameworkCore(cfg => +{ + cfg.AddContractsContainNamespaces(typeof(SomeContractAssemblyMarker).Assembly); + cfg.AddHandlersFromNamespaceContaining(); + cfg.AddNats(config => config + config.UseNats((context, bus) => + { + bus.Host(host, c => + { + c.Username(userName); + c.Password(password); + }); + bus.ConfigureEndpoints(context); + }); + ); + +}); +``` +That All, enjoy your moment! + + +| Package Name | Description | .NET Version | Document | +|----------------------------------------------------------|-------------------------------------------------------------------------------------------------|--------------|------------------------------------------------------------------------------------------| +| [OfX](https://www.nuget.org/packages/OfX/) | OfX core | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/README.md) | +| [OfX-EFCore](https://www.nuget.org/packages/OfX-EFCore/) | This is the OfX extension package using EntityFramework to fetch data | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.EntityFrameworkCore/README.md) | +| [OfX-gRPC](https://www.nuget.org/packages/OfX-gRPC/) | OfX.gRPC is an extension package for OfX that leverages gRPC for efficient data transportation. | 8.0, 9.0 | This Document | + +--- \ No newline at end of file