-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
129 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,68 @@ | ||
# 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) | ||
|
||
--- | ||
|
||
## 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<SomeHandlerAssemblyMarker>(); | ||
}) | ||
.AddOfXEFCore(options => | ||
{ | ||
options.AddDbContexts(typeof(TestDbContext)); | ||
options.AddModelConfigurationsFromNamespaceContaining<SomeModelAssemblyMarker>(); | ||
}); | ||
``` | ||
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<UserOfAttribute>(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 | | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks> | ||
<LangVersion>default</LangVersion> | ||
<Version>3.1.1</Version> | ||
<PackageIcon>OfX.png</PackageIcon> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\OfX\OfX.csproj"/> | ||
<None Include="..\..\LICENSE" Pack="true" PackagePath="\"/> | ||
<None Include="README.md" Pack="true" PackagePath="\"/> | ||
<None Include="..\..\OfX.png"> | ||
<Pack>True</Pack> | ||
<PackagePath/> | ||
<Link>OfX.png</Link> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<SomeHandlerAssemblyMarker>(); | ||
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 | | ||
|
||
--- |