Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New version 6.0.4 which updates Semantic Kernel to 1.0.0-beta8 #15

Merged
merged 19 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
54f0ac1
- Updated Semantic Kernel references from version `0.20.230821.4-prev…
rliberoff Nov 27, 2023
b56a4ef
- Re-added the `virtual` property modifier removed accidentally.
rliberoff Nov 27, 2023
60dbcfd
- Fixing Sonar Analysis issue.
rliberoff Nov 27, 2023
0b36d8f
Updated with latest chantes from release `6.0.3`.
rliberoff Nov 27, 2023
476ac6e
- Fixed samples.
rliberoff Nov 28, 2023
92a0925
Minor fix.
rliberoff Nov 28, 2023
318dfdd
- Again, minor fix.
rliberoff Nov 28, 2023
1f61c32
Fixed samples to work with `Semantic Kernel` version `1.0.0-beta8`.
rliberoff Nov 28, 2023
87e1054
Added `Directory.Build.targets` at Samples level to prevent generatin…
rliberoff Nov 28, 2023
666baea
Additional Fixes/
rliberoff Nov 28, 2023
914a299
- New extension method `AddSemanticTextMemory` in `Encamina.Enmarcha.…
rliberoff Nov 28, 2023
42672b3
- Minor change.
rliberoff Nov 28, 2023
8e98f32
- Moved reference of `Microsoft.SemanticKernel.TemplateEngine.Basic` …
rliberoff Nov 29, 2023
d10c17e
Merge branch 'main' into @rliberoff/update_semantic_kernel
rliberoff Nov 29, 2023
96e610e
Updated code from PR comments.
rliberoff Nov 30, 2023
0d3635d
Added `Ignore Spelling` for all document connectors at `Encamina.Enma…
rliberoff Nov 30, 2023
99512b6
Removed configuration values for `Encamina.Enmarcha.Samples.SemanticK…
rliberoff Nov 30, 2023
2946e22
Added additional `seealso` documentation for method in `ILengthFuncti…
rliberoff Nov 30, 2023
c7201ff
Merge branch 'main' into @rliberoff/update_semantic_kernel
rliberoff Dec 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ jobs:
run: dotnet tool install --global dotnet-sonarscanner

- name: Sonar - Begin Analyze
env:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet-sonarscanner begin /k:"${{ secrets.SONAR_PROJECT_KEY }}" /o:"${{ secrets.SONAR_ORGANIZATION }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.exclusions="**/tst/**/*" /d:sonar.cs.opencover.reportsPaths="**/tst/**/coverage.opencover.xml"
run: dotnet-sonarscanner begin /k:"${{ secrets.SONAR_PROJECT_KEY }}" /o:"${{ secrets.SONAR_ORGANIZATION }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.exclusions="**/tst/**/*" /d:sonar.cs.opencover.reportsPaths="**/tst/**/coverage.opencover.xml"

- name: Test
run: dotnet test --nologo --no-restore --collect:"XPlat Code Coverage" --configuration ${{env.BuildConfiguration}} --settings coverlet.runsettings
Expand Down
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,42 @@ Also, any bug fix must start with the prefix

Previous classification is not required if changes are simple or all belong to the same category.

## [6.0.4]

### Important

This version updates the `Semantic Kernel` library to version `1.0.0-beta8`, which introduces a lot of breaking changes in the code that mostly translate into multiple obsolescence warnings. Eventually, newer versions of this library will fix these warnings once a final version of `Semantic Kernel` is used.

The main motivation for this update is to take advantage of the latest improvements in the `Semantic Kernel` library, like the `Stepwise Planner` or Function Calls, plus better integrations with LLMs like OpenAI, among many other improvements.

Sadly, some warnings regarding types or members obsolescence could not be addresses until the Microsoft team behind `Semantic Kernel` provides a final version of the library. So far, these warnings are:

- CS0618: *IKernel.PromptTemplateEngine' is obsolete: 'PromptTemplateEngine has been replaced with PromptTemplateFactory and will be null. If you pass an PromptTemplateEngine instance when creating a Kernel it will be wrapped in an instance of IPromptTemplateFactory. This will be removed in a future release.*
- CS0618: *ISKFunction.RequestSettings' is obsolete: 'Use PromptTemplateConfig.ModelSettings instead. This will be removed in a future release.*
- CS0618: *ISKFunction.SkillName' is obsolete: 'Methods, properties and classes which include Skill in the name have been renamed. Use ISKFunction.SkillName instead. This will be removed in a future release.*

### Breaking Changes

- Updated `Semantic Kernel` libraries to version `1.0.0-beta8`.
- `Encamina.Enmarcha.SemanticKernel.Abstractions`
* Removed method `ValidateAndThrowIfErrorOccurred`.
* Removed properties `ChatModelName`, `CompletionsModelName`, and `EmbeddingsModelName` from `SemanticKernelOptions`.
- The following methods do not throw an `ArgumentException` if the instance of `ISKFunction` is not a semantic function, since now `Semantic Kernel` does not longer differentiates between Semantic and Native functions:
* GetSemanticFunctionPromptAsync
* GetSemanticFunctionUsedTokensAsync
- The extension method `ImportQuestionAnsweringPlugin` in `Encamina.Enmarcha.SemanticKernel.Plugins.QuestionAnswering` does not import the Memory plugin anymore. If the usage of the Question Answering plugin requires memory support, use the `ImportQuestionAnsweringPluginWithMemory` extension method instead. Remember to add a valid instance of `ISemanticTextMemory` as a service in the dependency container.

### Major Changes

- New extension method `AddSemanticTextMemory` in `Encamina.Enmarcha.SemanticKernel.Connectors.Memory` to add a semantic text memory (i.e., `ISemanticTextMemory`) to the dependency container.
- New extension method `ImportQuestionAnsweringPluginWithMemory` in `Encamina.Enmarcha.SemanticKernel.Plugins.QuestionAnswering` to support memories when getting context for the Question Answering plugin. Remember to add a valid instance of `ISemanticTextMemory` as a service in the dependency container.
- Added `Directory.Build.targets` at Samples level to prevent generating NuGet packages of these projects.

### Minor Changes
- Renamed sample projects to match Microsoft's naming conventions.
- Sample projects also use the new `Semantic Kernel` library version `1.0.0-beta8`.
- Some boy scouting by editing the comments in the code to have correct grammar and fixing some StyleCop warnings.

## [6.0.3.20]

### **Major Changes**
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
</PropertyGroup>

<PropertyGroup>
<VersionPrefix>6.0.3.20</VersionPrefix>
<VersionPrefix>6.0.4.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>

<!--
Deterministic builds ensure that the same binary is produced regardless of the machine building it, including paths to sources stored in the symbols.
While deterministic builds are enabled by default in .NET SDK projects, there is an extra property (ContinuousIntegrationBuild) to set on the build server
to normalize stored file paths. These should not be enabled during local dev or the debugger won’t be able to find the local source files.
to normalize stored file paths. These should not be enabled during local development or the debugger won’t be able to find the local source files.
-->
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
Expand Down
51 changes: 29 additions & 22 deletions Enmarcha.sln
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,21 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encamina.Enmarcha.SemanticKernel.Abstractions", "src\Encamina.Enmarcha.SemanticKernel.Abstractions\Encamina.Enmarcha.SemanticKernel.Abstractions.csproj", "{04DA11A3-937C-4D0A-ABDA-65AE9E0FCA5C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{C082F40D-38BE-4283-829E-29346AF71EAE}"
ProjectSection(SolutionItems) = preProject
samples\Directory.Build.targets = samples\Directory.Build.targets
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{B9E33951-E387-4A80-A652-A908FCBB34F3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample_Data_CosmosDB", "samples\Data\Sample_Data_CosmosDB\Sample_Data_CosmosDB.csproj", "{264A9DAA-2556-479A-A0F0-20A1DE14AC44}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SemanticKernel", "SemanticKernel", "{43252034-27E2-4981-AC2D-EA986B287863}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample_Data_EntityFramework", "samples\Data\Sample_Data_EntityFramework\Sample_Data_EntityFramework.csproj", "{68E17F14-A683-450C-A557-F27F4DF4DFD9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encamina.Enmarcha.Samples.Data.CosmosDB", "samples\Data\Encamina.Enmarcha.Samples.Data.CosmosDB\Encamina.Enmarcha.Samples.Data.CosmosDB.csproj", "{D2463070-D856-41B7-93DE-888E59885CD2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SemanticKernel", "SemanticKernel", "{43252034-27E2-4981-AC2D-EA986B287863}"
ProjectSection(SolutionItems) = preProject
samples\SemanticKernel\Sample_SemanticKernel_Text\Sample_SemanticKernel_Text.csproj = samples\SemanticKernel\Sample_SemanticKernel_Text\Sample_SemanticKernel_Text.csproj
EndProjectSection
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encamina.Enmarcha.Samples.Data.EntityFramework", "samples\Data\Encamina.Enmarcha.Samples.Data.EntityFramework\Encamina.Enmarcha.Samples.Data.EntityFramework.csproj", "{BF6C4DFC-3CB3-4C62-8B86-08C0C1537CBC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encamina.Enmarcha.Samples.SemanticKernel.Text", "samples\SemanticKernel\Encamina.Enmarcha.Samples.SemanticKernel.Text\Encamina.Enmarcha.Samples.SemanticKernel.Text.csproj", "{9E8B3AEE-AC1C-4F46-A8D2-3EF550F64005}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample_SemanticKernel_QuestionAnswering", "samples\SemanticKernel\Sample_SemanticKernel_QuestionAnswering\Sample_SemanticKernel_QuestionAnswering.csproj", "{661506FB-E0A7-4D6E-997F-A5CA12315424}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encamina.Enmarcha.Samples.SemanticKernel.QuestionAnswering", "samples\SemanticKernel\Encamina.Enmarcha.Samples.SemanticKernel.QuestionAnswering\Encamina.Enmarcha.Samples.SemanticKernel.QuestionAnswering.csproj", "{AA1E5E93-FE02-4395-9260-C7C869F22785}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -328,18 +330,22 @@ Global
{04DA11A3-937C-4D0A-ABDA-65AE9E0FCA5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04DA11A3-937C-4D0A-ABDA-65AE9E0FCA5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04DA11A3-937C-4D0A-ABDA-65AE9E0FCA5C}.Release|Any CPU.Build.0 = Release|Any CPU
{264A9DAA-2556-479A-A0F0-20A1DE14AC44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{264A9DAA-2556-479A-A0F0-20A1DE14AC44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{264A9DAA-2556-479A-A0F0-20A1DE14AC44}.Release|Any CPU.ActiveCfg = Release|Any CPU
{264A9DAA-2556-479A-A0F0-20A1DE14AC44}.Release|Any CPU.Build.0 = Release|Any CPU
{68E17F14-A683-450C-A557-F27F4DF4DFD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68E17F14-A683-450C-A557-F27F4DF4DFD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68E17F14-A683-450C-A557-F27F4DF4DFD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68E17F14-A683-450C-A557-F27F4DF4DFD9}.Release|Any CPU.Build.0 = Release|Any CPU
{661506FB-E0A7-4D6E-997F-A5CA12315424}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{661506FB-E0A7-4D6E-997F-A5CA12315424}.Debug|Any CPU.Build.0 = Debug|Any CPU
{661506FB-E0A7-4D6E-997F-A5CA12315424}.Release|Any CPU.ActiveCfg = Release|Any CPU
{661506FB-E0A7-4D6E-997F-A5CA12315424}.Release|Any CPU.Build.0 = Release|Any CPU
{D2463070-D856-41B7-93DE-888E59885CD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2463070-D856-41B7-93DE-888E59885CD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2463070-D856-41B7-93DE-888E59885CD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2463070-D856-41B7-93DE-888E59885CD2}.Release|Any CPU.Build.0 = Release|Any CPU
{BF6C4DFC-3CB3-4C62-8B86-08C0C1537CBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BF6C4DFC-3CB3-4C62-8B86-08C0C1537CBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF6C4DFC-3CB3-4C62-8B86-08C0C1537CBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF6C4DFC-3CB3-4C62-8B86-08C0C1537CBC}.Release|Any CPU.Build.0 = Release|Any CPU
{9E8B3AEE-AC1C-4F46-A8D2-3EF550F64005}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E8B3AEE-AC1C-4F46-A8D2-3EF550F64005}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E8B3AEE-AC1C-4F46-A8D2-3EF550F64005}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E8B3AEE-AC1C-4F46-A8D2-3EF550F64005}.Release|Any CPU.Build.0 = Release|Any CPU
{AA1E5E93-FE02-4395-9260-C7C869F22785}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AA1E5E93-FE02-4395-9260-C7C869F22785}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA1E5E93-FE02-4395-9260-C7C869F22785}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA1E5E93-FE02-4395-9260-C7C869F22785}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -350,10 +356,11 @@ Global
{E8152699-CECB-4BF5-884F-0A760554286E} = {CBD50B5F-AFB8-4DA1-9FD7-17D98EB3ED78}
{60C7833C-1E40-4725-8561-D86B424D78A5} = {CBD50B5F-AFB8-4DA1-9FD7-17D98EB3ED78}
{B9E33951-E387-4A80-A652-A908FCBB34F3} = {C082F40D-38BE-4283-829E-29346AF71EAE}
{264A9DAA-2556-479A-A0F0-20A1DE14AC44} = {B9E33951-E387-4A80-A652-A908FCBB34F3}
{68E17F14-A683-450C-A557-F27F4DF4DFD9} = {B9E33951-E387-4A80-A652-A908FCBB34F3}
{43252034-27E2-4981-AC2D-EA986B287863} = {C082F40D-38BE-4283-829E-29346AF71EAE}
{661506FB-E0A7-4D6E-997F-A5CA12315424} = {43252034-27E2-4981-AC2D-EA986B287863}
{D2463070-D856-41B7-93DE-888E59885CD2} = {B9E33951-E387-4A80-A652-A908FCBB34F3}
{BF6C4DFC-3CB3-4C62-8B86-08C0C1537CBC} = {B9E33951-E387-4A80-A652-A908FCBB34F3}
{9E8B3AEE-AC1C-4F46-A8D2-3EF550F64005} = {43252034-27E2-4981-AC2D-EA986B287863}
{AA1E5E93-FE02-4395-9260-C7C869F22785} = {43252034-27E2-4981-AC2D-EA986B287863}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F30DF47A-541C-4383-BCEB-E4108D06A70E}
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# ENMARCHA (Your package to accelerate .NET projects)
# ENMARCHA Your package to accelerate .NET projects

ENMARCHA aims to speed up the development of various .NET applications by leveraging robust modules that integrate with popular services and frameworks.

[![ENMARCHA NuGet](https://github.com/Encamina/enmarcha/actions/workflows/main.yml/badge.svg)](https://github.com/Encamina/enmarcha/actions/workflows/main.yml)

## 🚀 Modules

### 1. **AI with Azure AI Services (Cognitive Services)**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using Newtonsoft.Json;

namespace Sample_Data_CosmosDB;
public class Bill
namespace Encamina.Enmarcha.Samples.Data.CosmosDB;

internal class Bill
{
[JsonProperty("id")]
public string Id { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Encamina.Enmarcha.Data.Abstractions;

namespace Sample_Data_CosmosDB;
namespace Encamina.Enmarcha.Samples.Data.CosmosDB;

public class Bills
internal class Bills
{
private readonly IAsyncRepository<Bill> billsRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

using Sample_Data_CosmosDB;
namespace Encamina.Enmarcha.Samples.Data.CosmosDB;

internal sealed class Program
internal static class Program
{
private static async Task Main(string[] args)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Running the CosmosDB ENMARCHA Nuget sample
# Running the Cosmos DB with ENMARCHA

The CosmosDB ENMARCHA Nuget provides a highly useful transparent service to query information in Azure CosmosDB databases. Azure Cosmos DB is a fully managed NoSQL and relational database for modern app development. This guide will assist you in executing the sample.
The Cosmos DB ENMARCHA Nuget provides a highly useful transparent service to query information in Azure Cosmos DB databases. Azure Cosmos DB is a fully managed NoSQL and relational database for modern app development. This guide will assist you in executing the sample.

## Setup

- Use or generate a Cosmos DB in Azure. To generate a new CosmosDB, see [Azure CosmosDB documentation](https://azure.microsoft.com/es-es/free/cosmos-db/search/).
- Use or generate a Cosmos DB in Azure. To generate a new CosmosDB, see [Azure Cosmos DB documentation](https://azure.microsoft.com/es-es/free/cosmos-db/search/).
- Install Visual Studio. For more information, see [Visual Studio](https://visualstudio.microsoft.com).

## Steps

Here are the steps to follow to run the example properly:

- Use or generate a new CosmosDB database in Azure. Store the name of the database, the endpoint and the authorization key with read-write privileges in `appsettings.json`.
- Use or generate a new Cosmos DB database in Azure. Store the name of the database, the endpoint and the authorization key with read-write privileges in `appsettings.json`.
- Create a new Container in the database called `BILLS`, keep the default configuration.
- Open the solution `enmarcha.sln` in the start folder with Visual Studio.
- Go to Samples > Data right-click `Sample_Data_CosmosDB` project and click Set as Startup project.
- Go to Samples > Data right-click `Encamina.Enmarcha.Samples.Data.CosmosDB` project and click Set as Startup project.
- Click on the run button.

Once the program is running, a console will be displayed waiting for inputs. You can then indicate the actions you want to do.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"CosmosOptions": {
"AuthKey": "", // Authentication key required to connect with Azure Cosmos DB.
"Database": "", // Database name to connect with Azure Cosmos DB.
"Endpoint": "" // Azure Cosmos DB service endpoint to use.
},
"CosmosDBContainerName": "BILLS"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Encamina.Enmarcha.Samples.Data.EntityFramework;

internal class Bill : IEntity
{
public string Id { get; set; }

public string Concept { get; set; }

public double Amount { get; set; }

public string EmployeeId { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Encamina.Enmarcha.Samples.Data.EntityFramework;

internal class Employee : IEntity
{
public string Id { get; set; }

public string FullName { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Microsoft.EntityFrameworkCore;

namespace Encamina.Enmarcha.Samples.Data.EntityFramework;

internal class FinantialDBContext : DbContext
{
public DbSet<Bill> Bills { get; set; }

public DbSet<Employee> Employees { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
using Encamina.Enmarcha.Data.Abstractions;

namespace Sample_Data_EntityFramework;
namespace Encamina.Enmarcha.Samples.Data.EntityFramework;

public class FinantialOperations
internal class FinantialOperations
{
private readonly IFullUnitOfWork uow;
private readonly IFullUnitOfWork unitOfWork;

public FinantialOperations(IFullUnitOfWork uow)
public FinantialOperations(IFullUnitOfWork unitOfWork)
{
this.uow = uow;
this.unitOfWork = unitOfWork;
}

public async Task AddAsync<T>(T entity, CancellationToken cancellationToken)
where T : class, IEntity
{
var entityRepository = uow.GetAsyncRepository<T>();
var entityRepository = unitOfWork.GetAsyncRepository<T>();
await entityRepository.AddAsync(entity, cancellationToken);
await uow.SaveAsync(cancellationToken);
await unitOfWork.SaveAsync(cancellationToken);
}

public async Task<List<IEntity>> GetAllAsync<T>(CancellationToken cancellationToken)
where T : class, IEntity
{
var list = new List<IEntity>();
var entityRepository = uow.GetAsyncRepository<T>();
var entityRepository = unitOfWork.GetAsyncRepository<T>();
list.AddRange(await entityRepository.GetAllAsync(cancellationToken));
return list;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Encamina.Enmarcha.Data.EntityFramework;

namespace Encamina.Enmarcha.Samples.Data.EntityFramework;

internal class FinantialUnitOfWork : FullUnitOfWork
{
internal FinantialUnitOfWork(FinantialDBContext dBContext) : base(dBContext)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Encamina.Enmarcha.Samples.Data.EntityFramework;

internal interface IEntity
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

using Sample_Data_EntityFramework;
namespace Encamina.Enmarcha.Samples.Data.EntityFramework;

internal sealed class Program
internal static class Program
{
private static async Task Main(string[] args)
{
Expand Down Expand Up @@ -57,7 +57,7 @@ private static async Task Main(string[] args)
Console.WriteLine("Amount of the bill:");
var amount = double.Parse(Console.ReadLine());
await finantialSystemOperations.AddAsync(new Bill() { Amount = amount, Concept = concept, EmployeeId = selectedEmployee.Id }, CancellationToken.None);
Console.WriteLine("Bill succesfully uploaded");
Console.WriteLine("Bill successfully uploaded");
}

break;
Expand Down
Loading