diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..db2a596 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text eol=crlf \ No newline at end of file diff --git a/.github/workflows/cd-1.yml b/.github/workflows/cd-1.yml new file mode 100644 index 0000000..6746f68 --- /dev/null +++ b/.github/workflows/cd-1.yml @@ -0,0 +1,119 @@ +name: CD 1 + +on: + workflow_dispatch: + + pull_request: + branches: + - main + types: + - opened + - reopened + - synchronize + +permissions: + contents: write + +jobs: + + validate-source: + name: Validate Source Branch + runs-on: ubuntu-latest + + steps: + - name: Prevent Sources + run: | + set -euo pipefail + HEAD_REF="${{ github.head_ref }}" + echo "Head Branch: $HEAD_REF" + + if [ "$HEAD_REF" = "dev" ]; then + echo "Cannot merge into main from dev branch" + exit 1 + fi + + if [[ "$HEAD_REF" =~ ^vbump_[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9._-]+)?$ ]]; then + echo "Name matches version bump" + exit 0 + else + echo "Wrong source. Expected: vbump_{version}" + exit 1 + fi + + compare-versions: + needs: validate-source + name: Compare Versions + runs-on: ubuntu-latest + outputs: + version: ${{ steps.package_metadata.outputs.version }} + packages: ${{ steps.package_metadata.outputs.packages }} + + steps: + - name: CheckOut Base + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.base.ref }} + path: base + + - name: CheckOut Head + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + path: head + + - name: Read Base version + id: base_version + run: | + VERSION=$(jq -r '.version' base/csmpackage.json) + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Read Head version + id: head_version + run: | + VERSION=$(jq -r '.version' head/csmpackage.json) + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Compare versions + run: | + set -euo pipefail + + BASE="${{ steps.base_version.outputs.version }}" + HEAD="${{ steps.head_version.outputs.version }}" + BRANCH="${{ github.head_ref }}" + REGEX='^vbump[_-]([0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z._-]+)?(\+[0-9A-Za-z._-]+)?)$' + + echo "Base version: $BASE" + echo "Head version: $HEAD" + echo "Head Branch: $BRANCH" + + if [ "$BASE" = "$HEAD" ]; then + echo "Package metadata version isn't bumped" + exit 1 + fi + + if [[ $BRANCH =~ $REGEX ]]; then + BRANCH_VER="${BASH_REMATCH[1]}" + echo "Extracted version from branch: $BRANCH_VER" + else + echo "Branch name does not match required pattern: vbump_{version} or vbump-{version}" + echo "Examples: vbump_1.2.3, vbump-1.2.3-alpha, vbump_1.2.3+build.1" + exit 1 + fi + + if [ "$BRANCH_VER" = "$HEAD" ]; then + echo "Version match" + else + echo "Version mismatch: branch has '$BRANCH_VER' but metadata is '$HEAD'" + exit 1 + fi + + echo "Versions bumped correctly" + + - name: Expose Package Metadata + id: package_metadata + run: | + VERSION=$(jq -r '.version' head/csmpackage.json) + PACKAGES_JSON=$(jq -c '.packages' head/csmpackage.json) + + printf '%s\n' "version=$VERSION" >> $GITHUB_OUTPUT + printf '%s\n' "packages=$PACKAGES_JSON" >> $GITHUB_OUTPUT diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..eae7c2f --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,133 @@ +name: CI + +on: + workflow_dispatch: + + pull_request: + branches: [dev, main] + types: [opened, reopened, synchronize] + +jobs: + style_analyze: + name: Code Analyze + runs-on: ubuntu-latest + + env: + WDIR: csharp_database_extension + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: 🔑 Configure NuGet to use GitHub Packages + env: + NUGET_AUTH_TOKEN: ${{ secrets.PUBLISH_PAT }} + run: | + dotnet nuget add source \ + "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \ + --name "github" \ + --username ${{ github.actor }} \ + --password "$NUGET_AUTH_TOKEN" \ + --store-password-in-clear-text + + - name: ⚙️ Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + + - name: Formatting style + working-directory: ${{ env.WDIR }} + run: dotnet format style --verify-no-changes + + - name: Formatting analyzer + working-directory: ${{ env.WDIR }} + run: dotnet format analyzers --verify-no-changes + + unit_testing: + name: Unit Testing + runs-on: ubuntu-latest + concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + + env: + WDIR: csharp_database_extension + TEST_PROJECT: "Unit Tests/Unit Tests.csproj" + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure NuGet (GitHub Packages) + env: + NUGET_AUTH_TOKEN: ${{ secrets.PUBLISH_PAT }} + run: | + dotnet nuget add source \ + "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \ + --name github \ + --username ${{ github.actor }} \ + --password "$NUGET_AUTH_TOKEN" \ + --store-password-in-clear-text + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '10.0.x' + + - name: Cache NuGet packages + uses: actions/cache@v3 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} + restore-keys: ${{ runner.os }}-nuget- + + - name: Restore dependencies + working-directory: ${{ env.WDIR }} + run: dotnet restore + + - name: Build with analyzers + working-directory: ${{ env.WDIR }} + run: dotnet build --no-restore --configuration Release -warnaserror + + - name: Run tests + working-directory: ${{ env.WDIR }} + run: dotnet test "$TEST_PROJECT" --no-build --configuration Release --verbosity normal + + code_analyze: + name: CodeQL Analysis + runs-on: ubuntu-latest + permissions: + security-events: write + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Configure NuGet (GitHub Packages) + env: + NUGET_AUTH_TOKEN: ${{ secrets.PUBLISH_PAT }} + run: | + dotnet nuget add source \ + "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \ + --name github \ + --username ${{ github.actor }} \ + --password "$NUGET_AUTH_TOKEN" \ + --store-password-in-clear-text + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: csharp + + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + + - name: Dependency Review (security) + uses: actions/dependency-review-action@v4 diff --git a/CSM Database Core/Abstractions/Interfaces/IDatabase.cs b/CSM Database Core/Abstractions/Interfaces/IDatabase.cs deleted file mode 100644 index f8c2cbe..0000000 --- a/CSM Database Core/Abstractions/Interfaces/IDatabase.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace CSM_Database_Core.Abstractions.Interfaces; - -/// -/// Represents a Database context. -/// -public interface IDatabase { - - /// - /// Database unique identification sign. - /// - string Sign { get; } - - /// - /// Validates database connection and configuration health. - /// - /// - /// Whether the validation process is strict, throwing exceptions on failures. - /// - /// - /// Whether the validation process was sucessful or not. - /// - bool Validate(bool strict = true); -} \ No newline at end of file diff --git a/CSM Database Core/CHANGELOG.md b/CSM Database Core/CHANGELOG.md deleted file mode 100644 index 4d90278..0000000 --- a/CSM Database Core/CHANGELOG.md +++ /dev/null @@ -1,396 +0,0 @@ -# CSM Database Core CHANGELOG - -## [7.0.0] - 21.07-2026 - -### Changes - -- Now when database connection options weren't found on app assemblies a detailed console message is displayed on Design an Development time. - -### Breaks - -- Now [NamedEntity] have new properties definitions. - - - [Description]: Now it doesn't have length limit. - - [Name]: Now is unique along entities. - -- Renamed [DatabaseDesignFactoryBase] to [DatabaseDesignerBase] to keep shorter naming conventions with sense. -- Removed [CatalogEntity] and [ReferencedEntity] since [NamedEntities] have enough properties to deteermine an entity efficient search and constant referencing. - -### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 4.0.0 | 4.0.0 | -| Microsoft.EntityFrameworkCore | 10.0.9 | 10.0.10 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.9 | 10.0.10 | - -## [6.1.0] - 24.06-2026 - -### Changes - -- Now relations are able to be added no matter what direction of relationship they have at update operations. - -### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 4.0.0 | 4.0.0 | -| Microsoft.EntityFrameworkCore | 10.0.8 | 10.0.9 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.8 | 10.0.9 | - -## [6.0.6] - 18.06-2026 - -### Fixes - -- Fixed [DepotBase] [Update] method issue for a safe entity relation update just when the Ids are different. - -### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 4.0.0 | 4.0.0 | -| Microsoft.EntityFrameworkCore | 10.0.8 | 10.0.9 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.8 | 10.0.9 | - -## [6.0.5] - 18.06-2026 - -### Fixes - -- Fixed [DepotBase] [Update] method issue for a safe entity relation update just when the Ids are different. - -### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 4.0.0 | 4.0.0 | -| Microsoft.EntityFrameworkCore | 10.0.8 | 10.0.9 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.8 | 10.0.9 | - -## [6.0.4] - 18.06-2026 - -### Fixes - -- Fixed [DepotBase] [Update] method issue that was causing not relation inclussion on original entity object. - -### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 4.0.0 | 4.0.0 | -| Microsoft.EntityFrameworkCore | 10.0.8 | 10.0.9 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.8 | 10.0.9 | - -## [6.0.3] - 18.06-2026 - -### Fixes - -- Fixed [DepotBase] [Update] method issue that was causing miss calculation of Flat relations upgrading. - -### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 4.0.0 | 4.0.0 | -| Microsoft.EntityFrameworkCore | 10.0.8 | 10.0.9 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.8 | 10.0.9 | - -## [6.0.2] - 18.06-2026 - -### Fixes - -- Fixed [SanitizeEntity] issue that was causing wrong relation detections for collections. Removed deprecated dependants logic. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 4.0.0 | 4.0.0 | -| Microsoft.EntityFrameworkCore | 10.0.8 | 10.0.9 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.8 | 10.0.9 | - -## [6.0.1] - 18.06-2026 - -### Fixes - -- Fixed [SanitizeEntity] issue that was causing wrong relation detections for collections. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 4.0.0 | 4.0.0 | -| Microsoft.EntityFrameworkCore | 10.0.8 | 10.0.9 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.8 | 10.0.9 | - -## [6.0.0] - 18.06-2026 - -### Fixes - -- Fixed [SanitizeEntity] issue that was causing wrong relation detections for collections. - -### Removed - -- Removed [EntityDependencyAttribute] and [EntityDependantAttribute] now we only use [EntityRelation]. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 4.0.0 | 4.0.0 | -| Microsoft.EntityFrameworkCore | 10.0.8 | 10.0.9 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.8 | 10.0.9 | - -## [5.0.0] - 18.06-2026 - -### Changes - -- Removed [IRelationAttribute] unnecessary members. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 4.0.0 | 4.0.0 | -| Microsoft.EntityFrameworkCore | 10.0.8 | 10.0.9 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.8 | 10.0.9 | - -## [4.4.0] - 19.05-2026 - -### Changes - -- Reworked [Update] operations along depots for a easy management - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.1.0 | 4.0.0 | -| Microsoft.EntityFrameworkCore | 10.0.5 | 10.0.8 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.5 | 10.0.8 | - -## [4.3.1] - 16.03-2026 - -### Changes - -- Exposed package documentation. -- Added solution documentation. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.1.0 | 2.1.0 | -| Microsoft.EntityFrameworkCore | 10.0.3 | 10.0.5 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.3 | 10.0.5 | - -## [4.3.0] - 16.02-2026 - -### Fixed - -- Added [EntityBase{IEntity}] to correctly implement [Clone] features from [ObjectBase]. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.1.0 | 2.1.0 | -| Microsoft.EntityFrameworkCore | 10.0.3 | 10.0.3 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.3 | 10.0.3 | - -## [4.2.3] - 13.02-2026 - -### Fixed - -- Fixed an issue with [EntityError] that was not passing the [Exception] caught to its base, causing error handling errors. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.0.0 | 2.1.0 | -| Microsoft.EntityFrameworkCore | 10.0.1 | 10.0.3 | -| Microsoft.EntityFrameworkCore.SqlServer | 10.0.1 | 10.0.3 | - -## [4.2.0] - 29.01-2026 - -### Patched - -- Patched an error that was throwing errors about never finding connection options for Databases when searching at application assemblies. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.0.0 | 2.1.0 | -| Microsoft.EntityFrameworkCore | 9.0.8 | 10.0.1 | -| Microsoft.EntityFrameworkCore.SqlServer | 9.0.8 | 10.0.1 | - -## [4.1.2] - 24.12-2025 - -### Patched - -- Patched connection options tracing when the file is configured at machine / user environment variables. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.0.0 | 2.1.0 | -| Microsoft.EntityFrameworkCore | 9.0.8 | 10.0.1 | -| Microsoft.EntityFrameworkCore.SqlServer | 9.0.8 | 10.0.1 | - -## [4.1.1] - 22.12-2025 - -### Patched - -- Patched the way DatabaseUtils were locating connection options automatically for database context building, now using the correct application directory and not the assembly directory. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.0.0 | 2.0.0 | -| Microsoft.EntityFrameworkCore | 9.0.8 | 10.0.1 | -| Microsoft.EntityFrameworkCore.SqlServer | 9.0.8 | 10.0.1 | - -## [4.1.0] - 22.12-2025 - -### Added - -- Added a base class for database design ef context handling. - -### Changed - -- Updated packages and framework. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.0.0 | 2.0.0 | -| Microsoft.EntityFrameworkCore | 9.0.8 | 10.0.1 | -| Microsoft.EntityFrameworkCore.SqlServer | 9.0.8 | 10.0.1 | - -## [4.0.0] - 11.12-2025 - -### Changed - -- Reverted and removed version [3.0.0] interface concept is not needed in this abstraction layer. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.0.0 | 2.0.0 | -| Microsoft.EntityFrameworkCore | 9.0.8 | 9.0.8 | -| Microsoft.EntityFrameworkCore.SqlServer | 9.0.8 | 9.0.8 | - -## [3.0.0] - 26.11-2025 - -### Changed - -- Now DepotBase operations are based on interfaces trading instead of object classes. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.0.0 | 2.0.0 | -| Microsoft.EntityFrameworkCore | 9.0.8 | 9.0.8 | -| Microsoft.EntityFrameworkCore.SqlServer | 9.0.8 | 9.0.8 | - -## [2.1.0] - 26.11-2025 - -### Changed - -- Database activation based on testing purposes. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.0.0 | 2.0.0 | -| Microsoft.EntityFrameworkCore | 9.0.8 | 9.0.8 | -| Microsoft.EntityFrameworkCore.SqlServer | 9.0.8 | 9.0.8 | - - -## [2.0.1] - 25.11-2025 - -### Changed - -- Repository name. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.0.0 | 2.0.0 | -| Microsoft.EntityFrameworkCore | 9.0.8 | 9.0.8 | -| Microsoft.EntityFrameworkCore.SqlServer | 9.0.8 | 9.0.8 | - -## [2.0.0] - 24.11-2025 - -### Changed - -- File and abstraction organizations. -- Renaming of concepts. -- Added a way to get the [Sign] directly from [IDatabase] fro Testing Classes. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 1.3.0 | 2.0.0 | -| Microsoft.EntityFrameworkCore | 9.0.8 | 9.0.8 | -| Microsoft.EntityFrameworkCore.SqlServer | 9.0.8 | 9.0.8 | - -## [1.2.0] - 03.09-2025 - -### Added - -- A new [BActivableEntity] / [IActivableEntity] base added, that indicates an entity has [IsEnabled] property indicating if the object is enabled or no. - -- A new [BCatalogEntity] / [ICatalogEntity] base added, that indicates an entity is catalog referenced, meaning it has [Name], [Description], [IsEnabled] and a [Reference]. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 1.3.0 | 1.3.0 | -| Microsoft.EntityFrameworkCore | 9.0.8 | 9.0.8 | -| Microsoft.EntityFrameworkCore.SqlServer | 9.0.8 | 9.0.8 | - -## [1.1.0] - 06.08-2025 - -### Added - -- A new [ActivationReference] attribute was created to handle database contexts DbSet usage with interfaces setting a default reference as the activation at the database activation process. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 1.2.1 | 1.3.0 | -| Microsoft.EntityFrameworkCore | 9.0.8 | 9.0.8 | -| Microsoft.EntityFrameworkCore.SqlServer | 9.0.8 | 9.0.8 | - -## [1.0.0] - 06.08-2025 - -### Added - -- Package initialization. - -### Fixed - -### Changed - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | --.--.-- | 1.2.1 | -| Microsoft.EntityFrameworkCore | --.--.-- | 9.0.8 | -| Microsoft.EntityFrameworkCore.SqlServer | --.--.-- | 9.0.8 | -| xunit | --.--.-- | 2.9.3 | - -### Removed diff --git a/CSM Database Core/CSM Database Core.csproj b/CSM Database Core/CSM Database Core.csproj deleted file mode 100644 index 703a830..0000000 --- a/CSM Database Core/CSM Database Core.csproj +++ /dev/null @@ -1,29 +0,0 @@ - - - - net10.0 - CSM_Database_Core - CSM.Database.Core - 7.0.0 - Renato Urrea - Cosmos (CSM) - https://github.com/Cosmos-CSM/csm_database - enable - enable - true - CHANGELOG.md - true - true - - - - - - - - - - - - - diff --git a/CSM Database Core/Core/Attributes/Abstractions/Bases/RelationAttributeBase.cs b/CSM Database Core/Core/Attributes/Abstractions/Bases/RelationAttributeBase.cs deleted file mode 100644 index 4416745..0000000 --- a/CSM Database Core/Core/Attributes/Abstractions/Bases/RelationAttributeBase.cs +++ /dev/null @@ -1,21 +0,0 @@ -using CSM_Database_Core.Core.Attributes.Abstractions.Interfaces; - -namespace CSM_Database_Core.Core.Attributes.Abstractions.Bases; - -/// -public abstract class RelationAttributeBase - : Attribute, IRelationAttribute { - - /// - public string? Name { get; set; } - - /// - /// Creates a new instance. - /// - /// - /// Relation's name. - /// - public RelationAttributeBase(string? name = null) { - Name = name; - } -} diff --git a/CSM Database Core/Core/Attributes/Abstractions/Interfaces/IRelationAttribute.cs b/CSM Database Core/Core/Attributes/Abstractions/Interfaces/IRelationAttribute.cs deleted file mode 100644 index 0eaffe1..0000000 --- a/CSM Database Core/Core/Attributes/Abstractions/Interfaces/IRelationAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ - -using CSM_Database_Core.Entities.Abstractions.Interfaces; - -namespace CSM_Database_Core.Core.Attributes.Abstractions.Interfaces; - - -/// -/// Represents an relation attribute. -/// -public interface IRelationAttribute { - - /// - /// Relation name. - /// - public string? Name { get; set; } -} diff --git a/CSM Database Core/Entities/Abstractions/Bases/ActivableEntityBase.cs b/CSM Database Core/Entities/Abstractions/Bases/ActivableEntityBase.cs deleted file mode 100644 index d40b2dd..0000000 --- a/CSM Database Core/Entities/Abstractions/Bases/ActivableEntityBase.cs +++ /dev/null @@ -1,13 +0,0 @@ -using CSM_Database_Core.Entities.Abstractions.Interfaces; - -namespace CSM_Database_Core.Entities.Abstractions.Bases; - -/// -/// Represents an with enablement control. -/// -public abstract class ActivableEntityBase - : EntityBase, IEntity, IActivableEntity { - - /// - public bool IsEnabled { get; set; } = false; -} diff --git a/CSM Database Core/Entities/Abstractions/Bases/EntityBase.cs b/CSM Database Core/Entities/Abstractions/Bases/EntityBase.cs deleted file mode 100644 index b0b970c..0000000 --- a/CSM Database Core/Entities/Abstractions/Bases/EntityBase.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.ComponentModel.DataAnnotations.Schema; -using System.Reflection; -using System.Text.Json.Serialization; - -using CSM_Database_Core.Entities.Abstractions.Interfaces; -using CSM_Database_Core.Validation.Abstractions.Bases; - -using CSM_Foundation_Core.Abstractions.Bases; - -namespace CSM_Database_Core; - -/// -/// Represents a business entity. -/// -public abstract partial class EntityBase - : ObjectBase, IEntity { - - #region Server Side Properties - - /// - [NotMapped, JsonPropertyOrder(0)] - public string Discriminator { get; init; } - - /// - [NotMapped, JsonIgnore] - public abstract Type Database { get; init; } - - #endregion - - - /// - public long Id { get; set; } - - /// - public DateTime Timestamp { get; set; } = DateTime.UtcNow; - - /// - /// Creates a new instance. - /// - public EntityBase() { - Discriminator = $"{GetType().GUID}"; - } - - /// - protected void Evaluate() { - - foreach (PropertyInfo property in GetType().GetProperties()) { - - IEnumerable attributes = property.GetCustomAttributes(); - if (!attributes.Any()) - return; - - foreach (ValidatorBase validator in attributes) { - try { - validator.Validate(this); - } catch { - - } - } - } - } - - /// - public void EvaluateRead() { - Evaluate(); - } - - /// - public void EvaluateWrite() { - Evaluate(); - } - - /// - public Exception[] EvaluateDefinition() { - return []; - } -} \ No newline at end of file diff --git a/CSM Database Core/Entities/Abstractions/Bases/NamedEntityBase.cs b/CSM Database Core/Entities/Abstractions/Bases/NamedEntityBase.cs deleted file mode 100644 index 953d34a..0000000 --- a/CSM Database Core/Entities/Abstractions/Bases/NamedEntityBase.cs +++ /dev/null @@ -1,17 +0,0 @@ -using CSM_Database_Core.Entities.Abstractions.Interfaces; - -namespace CSM_Database_Core.Entities.Abstractions.Bases; - -/// -/// Represents an with and properties -/// that can help to identify a based on property as this defines them as unique. -/// -public abstract class NamedEntityBase - : EntityBase, INamedEntity { - - /// - public string Name { get; set; } = string.Empty; - - /// - public string? Description { get; set; } -} \ No newline at end of file diff --git a/CSM Database Core/Entities/Abstractions/Interfaces/IActivableEntity.cs b/CSM Database Core/Entities/Abstractions/Interfaces/IActivableEntity.cs deleted file mode 100644 index cf9876c..0000000 --- a/CSM Database Core/Entities/Abstractions/Interfaces/IActivableEntity.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CSM_Database_Core.Entities.Abstractions.Interfaces; -/// -/// Represents an with enablement control. -/// -public interface IActivableEntity - : IEntity { - - /// - /// Whether is enabled. - /// - bool IsEnabled { get; set; } -} \ No newline at end of file diff --git a/CSM Database Core/Entities/Abstractions/Interfaces/IEntity.cs b/CSM Database Core/Entities/Abstractions/Interfaces/IEntity.cs deleted file mode 100644 index 9427224..0000000 --- a/CSM Database Core/Entities/Abstractions/Interfaces/IEntity.cs +++ /dev/null @@ -1,68 +0,0 @@ - - -using System.ComponentModel.DataAnnotations.Schema; -using System.Text.Json.Serialization; - -using CSM_Foundation_Core.Convertion.Abstractions.Interfaces; - -namespace CSM_Database_Core.Entities.Abstractions.Interfaces; - -/// -/// Represents a tenant business live stored entity model, that usually are objects wich data are grouped by bound that -/// instrinsictly defines their own. -/// -public interface IEntity - : IConverterVariant { - - /// - /// Type of the implementation that stores this implementation. - /// - [JsonIgnore, NotMapped] - Type Database { get; init; } - - /// - /// Unique data storages direct pointer identifier. - /// - long Id { get; set; } - - /// - /// Time mark for the last time this got created and stored into data storage sources. - /// - DateTime Timestamp { get; set; } - - /// - /// This method evaluates the current record after being read from [Database] to determine - /// if all ist content is correctly reviewed, this is done because there might be a posibility that some users - /// or administration pushes data directly into the [Database] bypassing the system programmed validations. - /// - /// - /// This method can throw directly exceptions due to this kind of integrity methods are - /// strict and must mandatory break any kind of operation into the system to prevent - /// wrong usage and handling of corrupt data. - /// - /// - void EvaluateRead(); - - /// - /// This method evaluates the current record to be stored in the [Database] storage system, - /// this helps to keep the integrity of our data into our storage systems. - /// - /// - /// This method can throw directly exceptions due to this kind of integrity methods are - /// strict and must mandatory break any kind of operation into the system to prevent - /// wrong usage and handling of corrupt data. - /// - /// - void EvaluateWrite(); - - /// - /// This method is used to evaluate the implementation definition, this means will evaluate - /// if the and operations work as expected - /// before the system start its engine, this function might break the system rawSet up and stop advising - /// about the found exceptions. - /// - /// - /// Collection of exceptions found at definition evaluation. - /// - Exception[] EvaluateDefinition(); -} \ No newline at end of file diff --git a/CSM Database Core/Entities/Abstractions/Interfaces/INamedEntity.cs b/CSM Database Core/Entities/Abstractions/Interfaces/INamedEntity.cs deleted file mode 100644 index 2810d81..0000000 --- a/CSM Database Core/Entities/Abstractions/Interfaces/INamedEntity.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace CSM_Database_Core.Entities.Abstractions.Interfaces; - -/// -/// Represents an with and -/// that can help to identify a based on property as this defines them as unique. -/// -public interface INamedEntity - : IEntity { - - /// - /// Entity instance name. - /// - /// - /// Length must be between 1 and 100. - /// - [StringLength(100, MinimumLength = 1)] - string Name { get; set; } - - /// - /// Entity instance description. - /// - string? Description { get; set; } -} diff --git a/CSM Database Testing/CHANGELOG.md b/CSM Database Testing/CHANGELOG.md deleted file mode 100644 index 008f85d..0000000 --- a/CSM Database Testing/CHANGELOG.md +++ /dev/null @@ -1,257 +0,0 @@ -# CSM Database Testing CHANGELOG - -## [7.0.2] - 18.06-2026 - -### Removed - -- Removed drafting for [CatalogEntity] and [ReferencedEntity] since they were removed at version [7.0.0] of [CSM Database Core]. - -### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 4.0.0 | 4.0.0 | -| xunit.v3 | 3.2.2 | 3.2.2 | - -## [7.0.2] - 18.06-2026 - -### Fixed - -- Fixed code style - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.1.0 | 4.0.0 | -| xunit.v3 | 3.2.2 | 3.2.2 | - -## [7.0.1] - 18.06-2026 - -### Fixed - -- Fixed some [Store] method errors at [TestingStoreManager] that were missing entity sanitization logic. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.1.0 | 4.0.0 | -| xunit.v3 | 3.2.2 | 3.2.2 | - -## [7.0.0] - 18.06-2026 - -### Fixed - -- Exposing as virtual some missing test cases from [DepotTestsBase]. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.1.0 | 4.0.0 | -| xunit.v3 | 3.2.2 | 3.2.2 | - -## [6.0.0] - 19.05-2026 - -### Changes - -- Updated [TestingStoreManager] to handle sanitized data for integration testing iterations. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.1.0 | 4.0.0 | -| xunit.v3 | 3.2.2 | 3.2.2 | - -## [5.1.0] - 16.03-2026 - -### Changes - -- Now testing base methods names have a better description of the test itself. -- Now [Update_Success] tests is required to be implemented since there're special checks. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.1.0 | 2.1.0 | -| xunit.v3 | 3.2.2 | 3.2.2 | - -## [5.0.1] - 16.03-2026 - -### Changed - -- Exposed package documentation. -- Added solution documentation. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.1.0 | 2.1.0 | -| xunit.v3 | 3.2.2 | 3.2.2 | - -## [5.0.0] - 15.02-2026 - -### Changed - -- Removed [xunit] and [SkippableFact] packages for [xunit.v3] upgrade. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.1.0 | 2.1.0 | -| xunit.v3 | -.-.- | 3.2.2 | -| xunit | x.x.x | x.x.x | - -## [4.1.1] - 24.12-2025 - -### Changed - -- Updated packages and framework. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.0.0 | 2.1.0 | -| xunit | 2.9.3 | 2.9.3 | -| xunit.SkippableFact | 1.5.23 | 1.5.23 | - -## [4.1.1] - 22.12-2025 - -### Changed - -- Updated packages and framework. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.0.0 | 2.0.0 | -| xunit | 2.9.3 | 2.9.3 | -| xunit.SkippableFact | 1.5.23 | 1.5.23 | - -## [4.1.0] - 16.12-2025 - -### Added - -- Added new [BaseDraftUtils] to draft entities based on their base classes, simplifying data mocking. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 2.0.0 | 2.0.0 | -| xunit | 2.9.3 | 2.9.3 | -| xunit.SkippableFact | 1.5.23 | 1.5.23 | - -## [4.0.0] - 11.12-2025 - -### Changed - -- Reverted and removed version [3.0.0], the interface are not needed in this context abstraction level - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 1.3.1 | 2.0.0 | -| xunit | 2.9.3 | 2.9.3 | -| xunit.SkippableFact | 1.5.23 | 1.5.23 | - -## [3.0.0] - 11.12-2025 - -### Changed - -- Changed [TestDepotBase] to handle correctly interfacing for operations. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 1.3.1 | 2.0.0 | -| xunit | 2.9.3 | 2.9.3 | -| xunit.SkippableFact | 1.5.23 | 1.5.23 | - -## [2.1.0] - 26.11-2025 - -### Changed - -- Added database activation for testing purposes. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 1.3.1 | 1.3.0 | -| xunit | 2.9.3 | 2.9.3 | -| xunit.SkippableFact | 1.5.23 | 1.5.23 | - -## [2.0.2] - 25.11-2025 - -### Changed - -- Removed unnecessary param from [TestingDepotBase] Sign. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 1.3.1 | 1.3.0 | -| xunit | 2.9.3 | 2.9.3 | -| xunit.SkippableFact | 1.5.23 | 1.5.23 | - -## [2.0.1] - 25.11-2025 - -### Changed - -- Simplified access for testing database activation using signature property. - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 1.3.1 | 1.3.0 | -| xunit | 2.9.3 | 2.9.3 | -| xunit.SkippableFact | 1.5.23 | 1.5.23 | - -## [2.0.0] - 24.11-2025 - -### Added - -- Package initialization. - -### Changed - -- Renaming of abstractions and organization. -- Renaming of [Q_EntityValidations] to [TestingEntityBase] - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | 1.2.1 | 1.3.0 | -| xunit | 2.9.3 | 2.9.3 | -| xunit.SkippableFact | --.--.-- | 1.5.23 | - - -## [1.0.0] - 06.08-2025 - -### Added - -- Package initialization. - -### Fixed - -### Changed - -#### Dependencies - -| Package | Previous Version | New Version | -|:----------------------------------------|:----------------:|:---------------:| -| CSM.Foundation.Core | --.--.-- | 1.2.1 | -| xunit | --.--.-- | 2.9.3 | \ No newline at end of file diff --git a/CSM Database Testing/Disposing/Abstractions/Interfaces/ITestingDisposer.cs b/CSM Database Testing/Disposing/Abstractions/Interfaces/ITestingDisposer.cs deleted file mode 100644 index 00de600..0000000 --- a/CSM Database Testing/Disposing/Abstractions/Interfaces/ITestingDisposer.cs +++ /dev/null @@ -1,12 +0,0 @@ -using CSM_Database_Core.Entities.Abstractions.Interfaces; - -using CSM_Foundation_Core.Abstractions.Interfaces; - -namespace CSM_Database_Testing.Disposing.Abstractions.Interfaces; - -/// -/// Represents a testing data disposer context handler. -/// -public interface ITestingDisposer - : IDisposer { -} diff --git a/DatabaseProxy/Migrations/20260401220538_Init Db.Designer.cs b/DatabaseProxy/Migrations/20260401220538_Init Db.Designer.cs deleted file mode 100644 index 387484f..0000000 --- a/DatabaseProxy/Migrations/20260401220538_Init Db.Designer.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -using DatabaseProxy; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - [DbContext(typeof(DatabaseProxy))] - [Migration("20260401220538_Init Db")] - partial class InitDb - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); -#pragma warning restore 612, 618 - } - } -} diff --git a/DatabaseProxy/Migrations/20260401220538_Init Db.cs b/DatabaseProxy/Migrations/20260401220538_Init Db.cs deleted file mode 100644 index 9eada13..0000000 --- a/DatabaseProxy/Migrations/20260401220538_Init Db.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - /// - public partial class InitDb : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/DatabaseProxy/Migrations/20260401221950_Init_Db_2.Designer.cs b/DatabaseProxy/Migrations/20260401221950_Init_Db_2.Designer.cs deleted file mode 100644 index ad8135b..0000000 --- a/DatabaseProxy/Migrations/20260401221950_Init_Db_2.Designer.cs +++ /dev/null @@ -1,118 +0,0 @@ -// -using System; -using DatabaseProxy; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - [DbContext(typeof(DatabaseProxy))] - [Migration("20260401221950_Init_Db_2")] - partial class Init_Db_2 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("DatabaseProxy.EntityDependantProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityProxyId") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityProxyId"); - - b.ToTable("EntityDependantProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependencyProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.ToTable("EntityDependencyProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityDependencyProxyId") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityDependencyProxyId"); - - b.ToTable("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependantProxy", b => - { - b.HasOne("DatabaseProxy.EntityProxy", null) - .WithMany("Dependants") - .HasForeignKey("EntityProxyId"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.HasOne("DatabaseProxy.EntityDependencyProxy", null) - .WithMany("Dependants") - .HasForeignKey("EntityDependencyProxyId"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependencyProxy", b => - { - b.Navigation("Dependants"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.Navigation("Dependants"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DatabaseProxy/Migrations/20260401221950_Init_Db_2.cs b/DatabaseProxy/Migrations/20260401221950_Init_Db_2.cs deleted file mode 100644 index 820c7cc..0000000 --- a/DatabaseProxy/Migrations/20260401221950_Init_Db_2.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - /// - public partial class Init_Db_2 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "EntityDependencyProxies", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Timestamp = table.Column(type: "datetime2(7)", nullable: false, defaultValueSql: "GETUTCDATE()") - }, - constraints: table => - { - table.PrimaryKey("PK_EntityDependencyProxies", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "EntityProxies", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - EntityDependencyProxyId = table.Column(type: "bigint", nullable: true), - Timestamp = table.Column(type: "datetime2(7)", nullable: false, defaultValueSql: "GETUTCDATE()") - }, - constraints: table => - { - table.PrimaryKey("PK_EntityProxies", x => x.Id); - table.ForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_EntityDependencyProxyId", - column: x => x.EntityDependencyProxyId, - principalTable: "EntityDependencyProxies", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "EntityDependantProxies", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - EntityProxyId = table.Column(type: "bigint", nullable: true), - Timestamp = table.Column(type: "datetime2(7)", nullable: false, defaultValueSql: "GETUTCDATE()") - }, - constraints: table => - { - table.PrimaryKey("PK_EntityDependantProxies", x => x.Id); - table.ForeignKey( - name: "FK_EntityDependantProxies_EntityProxies_EntityProxyId", - column: x => x.EntityProxyId, - principalTable: "EntityProxies", - principalColumn: "Id"); - }); - - migrationBuilder.CreateIndex( - name: "IX_EntityDependantProxies_EntityProxyId", - table: "EntityDependantProxies", - column: "EntityProxyId"); - - migrationBuilder.CreateIndex( - name: "IX_EntityProxies_EntityDependencyProxyId", - table: "EntityProxies", - column: "EntityDependencyProxyId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "EntityDependantProxies"); - - migrationBuilder.DropTable( - name: "EntityProxies"); - - migrationBuilder.DropTable( - name: "EntityDependencyProxies"); - } - } -} diff --git a/DatabaseProxy/Migrations/20260506231958_added_autoloading.Designer.cs b/DatabaseProxy/Migrations/20260506231958_added_autoloading.Designer.cs deleted file mode 100644 index 527843f..0000000 --- a/DatabaseProxy/Migrations/20260506231958_added_autoloading.Designer.cs +++ /dev/null @@ -1,133 +0,0 @@ -// -using System; -using DatabaseProxy; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - [DbContext(typeof(DatabaseProxy))] - [Migration("20260506231958_added_autoloading")] - partial class added_autoloading - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("DatabaseProxy.EntityDependantProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityProxyId") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityProxyId"); - - b.ToTable("EntityDependantProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependencyProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.ToTable("EntityDependencyProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DependencyShadow") - .HasColumnType("bigint") - .HasColumnName("Dependency"); - - b.Property("EntityDependencyProxyId") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("DependencyShadow") - .IsUnique() - .HasFilter("[Dependency] IS NOT NULL"); - - b.HasIndex("EntityDependencyProxyId"); - - b.ToTable("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependantProxy", b => - { - b.HasOne("DatabaseProxy.EntityProxy", null) - .WithMany("Dependants") - .HasForeignKey("EntityProxyId"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.HasOne("DatabaseProxy.EntityDependencyProxy", "Dependency") - .WithOne() - .HasForeignKey("DatabaseProxy.EntityProxy", "DependencyShadow") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("DatabaseProxy.EntityDependencyProxy", null) - .WithMany("Dependants") - .HasForeignKey("EntityDependencyProxyId"); - - b.Navigation("Dependency"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependencyProxy", b => - { - b.Navigation("Dependants"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.Navigation("Dependants"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DatabaseProxy/Migrations/20260506231958_added_autoloading.cs b/DatabaseProxy/Migrations/20260506231958_added_autoloading.cs deleted file mode 100644 index f906b78..0000000 --- a/DatabaseProxy/Migrations/20260506231958_added_autoloading.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - /// - public partial class added_autoloading : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Dependency", - table: "EntityProxies", - type: "bigint", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_EntityProxies_Dependency", - table: "EntityProxies", - column: "Dependency", - unique: true, - filter: "[Dependency] IS NOT NULL"); - - migrationBuilder.AddForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_Dependency", - table: "EntityProxies", - column: "Dependency", - principalTable: "EntityDependencyProxies", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_Dependency", - table: "EntityProxies"); - - migrationBuilder.DropIndex( - name: "IX_EntityProxies_Dependency", - table: "EntityProxies"); - - migrationBuilder.DropColumn( - name: "Dependency", - table: "EntityProxies"); - } - } -} diff --git a/DatabaseProxy/Migrations/20260506232702_added_renamings.Designer.cs b/DatabaseProxy/Migrations/20260506232702_added_renamings.Designer.cs deleted file mode 100644 index 1383369..0000000 --- a/DatabaseProxy/Migrations/20260506232702_added_renamings.Designer.cs +++ /dev/null @@ -1,133 +0,0 @@ -// -using System; -using DatabaseProxy; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - [DbContext(typeof(DatabaseProxy))] - [Migration("20260506232702_added_renamings")] - partial class added_renamings - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("DatabaseProxy.EntityDependantProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityProxyId") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityProxyId"); - - b.ToTable("EntityDependantProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependencyProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.ToTable("EntityDependencyProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityDependencyProxyId") - .HasColumnType("bigint"); - - b.Property("EntityDependencyProxyShadow") - .HasColumnType("bigint") - .HasColumnName("EntityDependencyProxy"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityDependencyProxyId"); - - b.HasIndex("EntityDependencyProxyShadow") - .IsUnique() - .HasFilter("[EntityDependencyProxy] IS NOT NULL"); - - b.ToTable("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependantProxy", b => - { - b.HasOne("DatabaseProxy.EntityProxy", null) - .WithMany("EntityDependantProxies") - .HasForeignKey("EntityProxyId"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.HasOne("DatabaseProxy.EntityDependencyProxy", null) - .WithMany("Dependants") - .HasForeignKey("EntityDependencyProxyId"); - - b.HasOne("DatabaseProxy.EntityDependencyProxy", "EntityDependencyProxy") - .WithOne() - .HasForeignKey("DatabaseProxy.EntityProxy", "EntityDependencyProxyShadow") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("EntityDependencyProxy"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependencyProxy", b => - { - b.Navigation("Dependants"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.Navigation("EntityDependantProxies"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DatabaseProxy/Migrations/20260506232702_added_renamings.cs b/DatabaseProxy/Migrations/20260506232702_added_renamings.cs deleted file mode 100644 index e058d1f..0000000 --- a/DatabaseProxy/Migrations/20260506232702_added_renamings.cs +++ /dev/null @@ -1,74 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - /// - public partial class added_renamings : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_Dependency", - table: "EntityProxies"); - - migrationBuilder.DropIndex( - name: "IX_EntityProxies_Dependency", - table: "EntityProxies"); - - migrationBuilder.RenameColumn( - name: "Dependency", - table: "EntityProxies", - newName: "EntityDependencyProxy"); - - migrationBuilder.CreateIndex( - name: "IX_EntityProxies_EntityDependencyProxy", - table: "EntityProxies", - column: "EntityDependencyProxy", - unique: true, - filter: "[EntityDependencyProxy] IS NOT NULL"); - - migrationBuilder.AddForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_EntityDependencyProxy", - table: "EntityProxies", - column: "EntityDependencyProxy", - principalTable: "EntityDependencyProxies", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_EntityDependencyProxy", - table: "EntityProxies"); - - migrationBuilder.DropIndex( - name: "IX_EntityProxies_EntityDependencyProxy", - table: "EntityProxies"); - - migrationBuilder.RenameColumn( - name: "EntityDependencyProxy", - table: "EntityProxies", - newName: "Dependency"); - - migrationBuilder.CreateIndex( - name: "IX_EntityProxies_Dependency", - table: "EntityProxies", - column: "Dependency", - unique: true, - filter: "[Dependency] IS NOT NULL"); - - migrationBuilder.AddForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_Dependency", - table: "EntityProxies", - column: "Dependency", - principalTable: "EntityDependencyProxies", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - } -} diff --git a/DatabaseProxy/Migrations/20260506232938_added_attributes.Designer.cs b/DatabaseProxy/Migrations/20260506232938_added_attributes.Designer.cs deleted file mode 100644 index 0456cdf..0000000 --- a/DatabaseProxy/Migrations/20260506232938_added_attributes.Designer.cs +++ /dev/null @@ -1,133 +0,0 @@ -// -using System; -using DatabaseProxy; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - [DbContext(typeof(DatabaseProxy))] - [Migration("20260506232938_added_attributes")] - partial class added_attributes - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("DatabaseProxy.EntityDependantProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityProxyId") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityProxyId"); - - b.ToTable("EntityDependantProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependencyProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.ToTable("EntityDependencyProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityDependencyProxyId") - .HasColumnType("bigint"); - - b.Property("EntityDependencyProxyShadow") - .HasColumnType("bigint") - .HasColumnName("EntityDependencyProxy"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityDependencyProxyId"); - - b.HasIndex("EntityDependencyProxyShadow") - .IsUnique() - .HasFilter("[EntityDependencyProxy] IS NOT NULL"); - - b.ToTable("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependantProxy", b => - { - b.HasOne("DatabaseProxy.EntityProxy", null) - .WithMany("EntityDependantProxies") - .HasForeignKey("EntityProxyId"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.HasOne("DatabaseProxy.EntityDependencyProxy", null) - .WithMany("EntityProxies") - .HasForeignKey("EntityDependencyProxyId"); - - b.HasOne("DatabaseProxy.EntityDependencyProxy", "EntityDependencyProxy") - .WithOne() - .HasForeignKey("DatabaseProxy.EntityProxy", "EntityDependencyProxyShadow") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("EntityDependencyProxy"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependencyProxy", b => - { - b.Navigation("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.Navigation("EntityDependantProxies"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DatabaseProxy/Migrations/20260506232938_added_attributes.cs b/DatabaseProxy/Migrations/20260506232938_added_attributes.cs deleted file mode 100644 index b535c53..0000000 --- a/DatabaseProxy/Migrations/20260506232938_added_attributes.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - /// - public partial class added_attributes : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/DatabaseProxy/Migrations/20260506233726_added_attributes_2.Designer.cs b/DatabaseProxy/Migrations/20260506233726_added_attributes_2.Designer.cs deleted file mode 100644 index bd8b13f..0000000 --- a/DatabaseProxy/Migrations/20260506233726_added_attributes_2.Designer.cs +++ /dev/null @@ -1,118 +0,0 @@ -// -using System; -using DatabaseProxy; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - [DbContext(typeof(DatabaseProxy))] - [Migration("20260506233726_added_attributes_2")] - partial class added_attributes_2 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("DatabaseProxy.EntityDependantProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityProxyId") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityProxyId"); - - b.ToTable("EntityDependantProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependencyProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.ToTable("EntityDependencyProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityDependencyProxyId") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityDependencyProxyId"); - - b.ToTable("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependantProxy", b => - { - b.HasOne("DatabaseProxy.EntityProxy", null) - .WithMany("EntityDependantProxies") - .HasForeignKey("EntityProxyId"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.HasOne("DatabaseProxy.EntityDependencyProxy", null) - .WithMany("EntityProxies") - .HasForeignKey("EntityDependencyProxyId"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityDependencyProxy", b => - { - b.Navigation("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.EntityProxy", b => - { - b.Navigation("EntityDependantProxies"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DatabaseProxy/Migrations/20260506233726_added_attributes_2.cs b/DatabaseProxy/Migrations/20260506233726_added_attributes_2.cs deleted file mode 100644 index 7ebf990..0000000 --- a/DatabaseProxy/Migrations/20260506233726_added_attributes_2.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - /// - public partial class added_attributes_2 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_EntityDependencyProxy", - table: "EntityProxies"); - - migrationBuilder.DropIndex( - name: "IX_EntityProxies_EntityDependencyProxy", - table: "EntityProxies"); - - migrationBuilder.DropColumn( - name: "EntityDependencyProxy", - table: "EntityProxies"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "EntityDependencyProxy", - table: "EntityProxies", - type: "bigint", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_EntityProxies_EntityDependencyProxy", - table: "EntityProxies", - column: "EntityDependencyProxy", - unique: true, - filter: "[EntityDependencyProxy] IS NOT NULL"); - - migrationBuilder.AddForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_EntityDependencyProxy", - table: "EntityProxies", - column: "EntityDependencyProxy", - principalTable: "EntityDependencyProxies", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - } -} diff --git a/DatabaseProxy/Migrations/20260507000230_standarized db for proxies.Designer.cs b/DatabaseProxy/Migrations/20260507000230_standarized db for proxies.Designer.cs deleted file mode 100644 index c60f54d..0000000 --- a/DatabaseProxy/Migrations/20260507000230_standarized db for proxies.Designer.cs +++ /dev/null @@ -1,150 +0,0 @@ -// -using System; -using DatabaseProxy; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - [DbContext(typeof(DatabaseProxy))] - [Migration("20260507000230_standarized db for proxies")] -#pragma warning disable CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language. - partial class standarizeddbforproxies -#pragma warning restore CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language. - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependantProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityProxyId") - .HasColumnType("bigint"); - - b.Property("EntityProxyShadow") - .HasColumnType("bigint") - .HasColumnName("EntityProxy"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityProxyId"); - - b.HasIndex("EntityProxyShadow") - .IsUnique() - .HasFilter("[EntityProxy] IS NOT NULL"); - - b.ToTable("EntityDependantProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependencyProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.ToTable("EntityDependencyProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityDependencyProxyId") - .HasColumnType("bigint"); - - b.Property("EntityDependencyProxyShadow") - .HasColumnType("bigint") - .HasColumnName("EntityDependencyProxy"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityDependencyProxyId"); - - b.HasIndex("EntityDependencyProxyShadow") - .IsUnique() - .HasFilter("[EntityDependencyProxy] IS NOT NULL"); - - b.ToTable("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependantProxy", b => - { - b.HasOne("DatabaseProxy.Entities.EntityProxy", null) - .WithMany("EntityDependantProxies") - .HasForeignKey("EntityProxyId"); - - b.HasOne("DatabaseProxy.Entities.EntityProxy", "EntityProxy") - .WithOne() - .HasForeignKey("DatabaseProxy.Entities.EntityDependantProxy", "EntityProxyShadow") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("EntityProxy"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.HasOne("DatabaseProxy.Entities.EntityDependencyProxy", null) - .WithMany("EntityProxies") - .HasForeignKey("EntityDependencyProxyId"); - - b.HasOne("DatabaseProxy.Entities.EntityDependencyProxy", "EntityDependencyProxy") - .WithOne() - .HasForeignKey("DatabaseProxy.Entities.EntityProxy", "EntityDependencyProxyShadow") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("EntityDependencyProxy"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependencyProxy", b => - { - b.Navigation("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.Navigation("EntityDependantProxies"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DatabaseProxy/Migrations/20260507000230_standarized db for proxies.cs b/DatabaseProxy/Migrations/20260507000230_standarized db for proxies.cs deleted file mode 100644 index 35fe9a3..0000000 --- a/DatabaseProxy/Migrations/20260507000230_standarized db for proxies.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DatabaseProxy.Migrations; - -/// -#pragma warning disable CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language. -public partial class standarizeddbforproxies : Migration -#pragma warning restore CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language. -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "EntityDependencyProxy", - table: "EntityProxies", - type: "bigint", - nullable: true); - - migrationBuilder.AddColumn( - name: "EntityProxy", - table: "EntityDependantProxies", - type: "bigint", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_EntityProxies_EntityDependencyProxy", - table: "EntityProxies", - column: "EntityDependencyProxy", - unique: true, - filter: "[EntityDependencyProxy] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_EntityDependantProxies_EntityProxy", - table: "EntityDependantProxies", - column: "EntityProxy", - unique: true, - filter: "[EntityProxy] IS NOT NULL"); - - migrationBuilder.AddForeignKey( - name: "FK_EntityDependantProxies_EntityProxies_EntityProxy", - table: "EntityDependantProxies", - column: "EntityProxy", - principalTable: "EntityProxies", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - - migrationBuilder.AddForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_EntityDependencyProxy", - table: "EntityProxies", - column: "EntityDependencyProxy", - principalTable: "EntityDependencyProxies", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_EntityDependantProxies_EntityProxies_EntityProxy", - table: "EntityDependantProxies"); - - migrationBuilder.DropForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_EntityDependencyProxy", - table: "EntityProxies"); - - migrationBuilder.DropIndex( - name: "IX_EntityProxies_EntityDependencyProxy", - table: "EntityProxies"); - - migrationBuilder.DropIndex( - name: "IX_EntityDependantProxies_EntityProxy", - table: "EntityDependantProxies"); - - migrationBuilder.DropColumn( - name: "EntityDependencyProxy", - table: "EntityProxies"); - - migrationBuilder.DropColumn( - name: "EntityProxy", - table: "EntityDependantProxies"); - } -} diff --git a/DatabaseProxy/Migrations/20260507000851_standarized db for proxies 2.Designer.cs b/DatabaseProxy/Migrations/20260507000851_standarized db for proxies 2.Designer.cs deleted file mode 100644 index 63319b5..0000000 --- a/DatabaseProxy/Migrations/20260507000851_standarized db for proxies 2.Designer.cs +++ /dev/null @@ -1,137 +0,0 @@ -// -using System; -using DatabaseProxy; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - [DbContext(typeof(DatabaseProxy))] - [Migration("20260507000851_standarized db for proxies 2")] - partial class standarizeddbforproxies2 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependantProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityProxyId") - .HasColumnType("bigint"); - - b.Property("EntityProxyShadow") - .HasColumnType("bigint") - .HasColumnName("EntityProxy"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityProxyId"); - - b.HasIndex("EntityProxyShadow") - .IsUnique() - .HasFilter("[EntityProxy] IS NOT NULL"); - - b.ToTable("EntityDependantProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependencyProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.ToTable("EntityDependencyProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityDependencyProxyShadow") - .HasColumnType("bigint") - .HasColumnName("EntityDependencyProxy"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityDependencyProxyShadow"); - - b.ToTable("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependantProxy", b => - { - b.HasOne("DatabaseProxy.Entities.EntityProxy", null) - .WithMany("EntityDependantProxies") - .HasForeignKey("EntityProxyId"); - - b.HasOne("DatabaseProxy.Entities.EntityProxy", "EntityProxy") - .WithOne() - .HasForeignKey("DatabaseProxy.Entities.EntityDependantProxy", "EntityProxyShadow") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("EntityProxy"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.HasOne("DatabaseProxy.Entities.EntityDependencyProxy", "EntityDependencyProxy") - .WithMany("EntityProxies") - .HasForeignKey("EntityDependencyProxyShadow") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("EntityDependencyProxy"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependencyProxy", b => - { - b.Navigation("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.Navigation("EntityDependantProxies"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DatabaseProxy/Migrations/20260507000851_standarized db for proxies 2.cs b/DatabaseProxy/Migrations/20260507000851_standarized db for proxies 2.cs deleted file mode 100644 index ef4566a..0000000 --- a/DatabaseProxy/Migrations/20260507000851_standarized db for proxies 2.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - /// - public partial class standarizeddbforproxies2 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_EntityDependencyProxyId", - table: "EntityProxies"); - - migrationBuilder.DropIndex( - name: "IX_EntityProxies_EntityDependencyProxy", - table: "EntityProxies"); - - migrationBuilder.DropIndex( - name: "IX_EntityProxies_EntityDependencyProxyId", - table: "EntityProxies"); - - migrationBuilder.DropColumn( - name: "EntityDependencyProxyId", - table: "EntityProxies"); - - migrationBuilder.CreateIndex( - name: "IX_EntityProxies_EntityDependencyProxy", - table: "EntityProxies", - column: "EntityDependencyProxy"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_EntityProxies_EntityDependencyProxy", - table: "EntityProxies"); - - migrationBuilder.AddColumn( - name: "EntityDependencyProxyId", - table: "EntityProxies", - type: "bigint", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_EntityProxies_EntityDependencyProxy", - table: "EntityProxies", - column: "EntityDependencyProxy", - unique: true, - filter: "[EntityDependencyProxy] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_EntityProxies_EntityDependencyProxyId", - table: "EntityProxies", - column: "EntityDependencyProxyId"); - - migrationBuilder.AddForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_EntityDependencyProxyId", - table: "EntityProxies", - column: "EntityDependencyProxyId", - principalTable: "EntityDependencyProxies", - principalColumn: "Id"); - } - } -} diff --git a/DatabaseProxy/Migrations/20260507000955_standarized db for proxies 3.Designer.cs b/DatabaseProxy/Migrations/20260507000955_standarized db for proxies 3.Designer.cs deleted file mode 100644 index d531dcd..0000000 --- a/DatabaseProxy/Migrations/20260507000955_standarized db for proxies 3.Designer.cs +++ /dev/null @@ -1,126 +0,0 @@ -// -using System; -using DatabaseProxy; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - [DbContext(typeof(DatabaseProxy))] - [Migration("20260507000955_standarized db for proxies 3")] - partial class standarizeddbforproxies3 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependantProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityProxyShadow") - .HasColumnType("bigint") - .HasColumnName("EntityProxy"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityProxyShadow"); - - b.ToTable("EntityDependantProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependencyProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.ToTable("EntityDependencyProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityDependencyProxyShadow") - .HasColumnType("bigint") - .HasColumnName("EntityDependencyProxy"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityDependencyProxyShadow"); - - b.ToTable("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependantProxy", b => - { - b.HasOne("DatabaseProxy.Entities.EntityProxy", "EntityProxy") - .WithMany("EntityDependantProxies") - .HasForeignKey("EntityProxyShadow") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("EntityProxy"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.HasOne("DatabaseProxy.Entities.EntityDependencyProxy", "EntityDependencyProxy") - .WithMany("EntityProxies") - .HasForeignKey("EntityDependencyProxyShadow") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("EntityDependencyProxy"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependencyProxy", b => - { - b.Navigation("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.Navigation("EntityDependantProxies"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DatabaseProxy/Migrations/20260507000955_standarized db for proxies 3.cs b/DatabaseProxy/Migrations/20260507000955_standarized db for proxies 3.cs deleted file mode 100644 index 4d0fa16..0000000 --- a/DatabaseProxy/Migrations/20260507000955_standarized db for proxies 3.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - /// - public partial class standarizeddbforproxies3 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_EntityDependantProxies_EntityProxies_EntityProxyId", - table: "EntityDependantProxies"); - - migrationBuilder.DropIndex( - name: "IX_EntityDependantProxies_EntityProxy", - table: "EntityDependantProxies"); - - migrationBuilder.DropIndex( - name: "IX_EntityDependantProxies_EntityProxyId", - table: "EntityDependantProxies"); - - migrationBuilder.DropColumn( - name: "EntityProxyId", - table: "EntityDependantProxies"); - - migrationBuilder.CreateIndex( - name: "IX_EntityDependantProxies_EntityProxy", - table: "EntityDependantProxies", - column: "EntityProxy"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_EntityDependantProxies_EntityProxy", - table: "EntityDependantProxies"); - - migrationBuilder.AddColumn( - name: "EntityProxyId", - table: "EntityDependantProxies", - type: "bigint", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_EntityDependantProxies_EntityProxy", - table: "EntityDependantProxies", - column: "EntityProxy", - unique: true, - filter: "[EntityProxy] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_EntityDependantProxies_EntityProxyId", - table: "EntityDependantProxies", - column: "EntityProxyId"); - - migrationBuilder.AddForeignKey( - name: "FK_EntityDependantProxies_EntityProxies_EntityProxyId", - table: "EntityDependantProxies", - column: "EntityProxyId", - principalTable: "EntityProxies", - principalColumn: "Id"); - } - } -} diff --git a/DatabaseProxy/Migrations/20260619050113_IncludingCascadingDeletion.Designer.cs b/DatabaseProxy/Migrations/20260619050113_IncludingCascadingDeletion.Designer.cs deleted file mode 100644 index 6240d32..0000000 --- a/DatabaseProxy/Migrations/20260619050113_IncludingCascadingDeletion.Designer.cs +++ /dev/null @@ -1,126 +0,0 @@ -// -using System; -using DatabaseProxy; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - [DbContext(typeof(DatabaseProxy))] - [Migration("20260619050113_IncludingCascadingDeletion")] - partial class IncludingCascadingDeletion - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.9") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependantProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityProxyShadow") - .HasColumnType("bigint") - .HasColumnName("EntityProxy"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityProxyShadow"); - - b.ToTable("EntityDependantProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependencyProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.ToTable("EntityDependencyProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityDependencyProxyShadow") - .HasColumnType("bigint") - .HasColumnName("EntityDependencyProxy"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityDependencyProxyShadow"); - - b.ToTable("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependantProxy", b => - { - b.HasOne("DatabaseProxy.Entities.EntityProxy", "EntityProxy") - .WithMany("EntityDependantProxies") - .HasForeignKey("EntityProxyShadow") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("EntityProxy"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.HasOne("DatabaseProxy.Entities.EntityDependencyProxy", "EntityDependencyProxy") - .WithMany("EntityProxies") - .HasForeignKey("EntityDependencyProxyShadow") - .OnDelete(DeleteBehavior.Cascade); - - b.Navigation("EntityDependencyProxy"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependencyProxy", b => - { - b.Navigation("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.Navigation("EntityDependantProxies"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DatabaseProxy/Migrations/20260619050113_IncludingCascadingDeletion.cs b/DatabaseProxy/Migrations/20260619050113_IncludingCascadingDeletion.cs deleted file mode 100644 index 1b5d885..0000000 --- a/DatabaseProxy/Migrations/20260619050113_IncludingCascadingDeletion.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - /// - public partial class IncludingCascadingDeletion : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_EntityDependencyProxy", - table: "EntityProxies"); - - migrationBuilder.AddForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_EntityDependencyProxy", - table: "EntityProxies", - column: "EntityDependencyProxy", - principalTable: "EntityDependencyProxies", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_EntityDependencyProxy", - table: "EntityProxies"); - - migrationBuilder.AddForeignKey( - name: "FK_EntityProxies_EntityDependencyProxies_EntityDependencyProxy", - table: "EntityProxies", - column: "EntityDependencyProxy", - principalTable: "EntityDependencyProxies", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - } -} diff --git a/DatabaseProxy/Migrations/DatabaseProxyModelSnapshot.cs b/DatabaseProxy/Migrations/DatabaseProxyModelSnapshot.cs deleted file mode 100644 index 30523af..0000000 --- a/DatabaseProxy/Migrations/DatabaseProxyModelSnapshot.cs +++ /dev/null @@ -1,123 +0,0 @@ -// -using System; -using DatabaseProxy; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace DatabaseProxy.Migrations -{ - [DbContext(typeof(DatabaseProxy))] - partial class DatabaseProxyModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.9") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependantProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityProxyShadow") - .HasColumnType("bigint") - .HasColumnName("EntityProxy"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityProxyShadow"); - - b.ToTable("EntityDependantProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependencyProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.ToTable("EntityDependencyProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("EntityDependencyProxyShadow") - .HasColumnType("bigint") - .HasColumnName("EntityDependencyProxy"); - - b.Property("Timestamp") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - - b.HasKey("Id"); - - b.HasIndex("EntityDependencyProxyShadow"); - - b.ToTable("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependantProxy", b => - { - b.HasOne("DatabaseProxy.Entities.EntityProxy", "EntityProxy") - .WithMany("EntityDependantProxies") - .HasForeignKey("EntityProxyShadow") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("EntityProxy"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.HasOne("DatabaseProxy.Entities.EntityDependencyProxy", "EntityDependencyProxy") - .WithMany("EntityProxies") - .HasForeignKey("EntityDependencyProxyShadow") - .OnDelete(DeleteBehavior.Cascade); - - b.Navigation("EntityDependencyProxy"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityDependencyProxy", b => - { - b.Navigation("EntityProxies"); - }); - - modelBuilder.Entity("DatabaseProxy.Entities.EntityProxy", b => - { - b.Navigation("EntityDependantProxies"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/README.md b/README.md index 934ec96..45487d9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,25 @@ -# csm_foundation_database -A .Net package solution for database related core tools. +# *CSharp Database Extension* + +A repository for a framweork extensions package. Framweork extensions are CSM shaped utilities and tools for frameworks and languages used during development. + +> For more details about each version content, please consult [Changelog](./csharp_database_extension/CHANGELOG.md) + +## **Installation & Usage** + +> dotnet nuget add source --name "github" --username {*GITHUB.USR*} --password {*GITHUB.PAT*} "" + +* GITHUB.USR: It's your github user account. + +* GITHUB.PAT: It's a generated personal access token, go to *Settings* > *Developer Settings* > *Personal access tokens*, create a **Classic** type access token and provide at minimum **Read:Packages** permission. + +> dotnet add package **CSharp.Database.Extension** --source github + +## **Testing** + +A testing purposes package is included, provides tools to handle easier tests setup, configurations, and managament of classes. + +> dotnet add package **CSharp.Database.Extension.Testing** --source github + +Highly recommended only use on testing projects. + +> For more details about package content please consult [CHANGELOG]() \ No newline at end of file diff --git a/.editorconfig b/csharp_database_extension/.editorconfig similarity index 99% rename from .editorconfig rename to csharp_database_extension/.editorconfig index 384a997..e292354 100644 --- a/.editorconfig +++ b/csharp_database_extension/.editorconfig @@ -14,7 +14,7 @@ tab_width = 4 # New line preferences end_of_line = crlf -insert_final_newline = false +insert_final_newline = true #### .NET Coding Conventions #### diff --git a/.gitignore b/csharp_database_extension/.gitignore similarity index 100% rename from .gitignore rename to csharp_database_extension/.gitignore diff --git a/CHANGELOG.md b/csharp_database_extension/CHANGELOG.md similarity index 100% rename from CHANGELOG.md rename to csharp_database_extension/CHANGELOG.md diff --git a/CSM Database Testing/Abstractions/Bases/DatabaseIntegrationTestsBase.cs b/csharp_database_extension/CSharp Database Extension Testing/Abstractions/Bases/DatabaseIntegrationTestsBase.cs similarity index 87% rename from CSM Database Testing/Abstractions/Bases/DatabaseIntegrationTestsBase.cs rename to csharp_database_extension/CSharp Database Extension Testing/Abstractions/Bases/DatabaseIntegrationTestsBase.cs index 5f31b8e..59edb85 100644 --- a/CSM Database Testing/Abstractions/Bases/DatabaseIntegrationTestsBase.cs +++ b/csharp_database_extension/CSharp Database Extension Testing/Abstractions/Bases/DatabaseIntegrationTestsBase.cs @@ -1,15 +1,15 @@ -using CSM_Database_Core; -using CSM_Database_Core.Core.Models; +using CSharp_Database_Extension; +using CSharp_Database_Extension.Common.Models; -using CSM_Database_Testing.Abstractions.Interfaces; +using CSharp_Database_Extension_Testing.Abstractions.Interfaces; -using CSM_Foundation_Core.Core.Extensions; +using CSharp_Extension.Common.Extensions; using Microsoft.EntityFrameworkCore; using Xunit; -namespace CSM_Database_Testing.Abstractions.Bases; +namespace CSharp_Database_Extension_Testing.Abstractions.Bases; /// /// Represents a testing class for a Database context. diff --git a/CSM Database Testing/Abstractions/Bases/DepotIntegrationTestsBase.cs b/csharp_database_extension/CSharp Database Extension Testing/Abstractions/Bases/DepotIntegrationTestsBase.cs similarity index 92% rename from CSM Database Testing/Abstractions/Bases/DepotIntegrationTestsBase.cs rename to csharp_database_extension/CSharp Database Extension Testing/Abstractions/Bases/DepotIntegrationTestsBase.cs index d9ad720..537c779 100644 --- a/CSM Database Testing/Abstractions/Bases/DepotIntegrationTestsBase.cs +++ b/csharp_database_extension/CSharp Database Extension Testing/Abstractions/Bases/DepotIntegrationTestsBase.cs @@ -1,21 +1,20 @@ using System.Linq.Expressions; using System.Reflection; -using CSM_Database_Core; -using CSM_Database_Core.Core.Errors; -using CSM_Database_Core.Core.Models; -using CSM_Database_Core.Depots.Abstractions.Interfaces; -using CSM_Database_Core.Depots.Models; -using CSM_Database_Core.Depots.ViewFilters; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension; +using CSharp_Database_Extension.Common.Errors; +using CSharp_Database_Extension.Common.Models; +using CSharp_Database_Extension.Depots.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Models; +using CSharp_Database_Extension.Depots.ViewFilters; -using CSM_Database_Testing.Disposing.Abstractions.Bases; -using CSM_Database_Testing.Managers; +using CSharp_Database_Extension_Testing.Disposing.Abstractions.Bases; +using CSharp_Database_Extension_Testing.Managers; using Xunit; using Xunit.Sdk; -namespace CSM_Database_Testing.Abstractions.Bases; +namespace CSharp_Database_Extension_Testing.Abstractions.Bases; /// /// Represents a testing base class for a data source depot. @@ -27,7 +26,7 @@ namespace CSM_Database_Testing.Abstractions.Bases; /// Type of the being tested. /// /// -/// Type of the handling the . +/// Type of the handling the . /// public abstract class DepotIntegrationTestsBase : TestingDataHandlerBase @@ -61,17 +60,17 @@ public abstract class DepotIntegrationTestsBase /// public DepotIntegrationTestsBase(DatabaseFactory? database = null, params DatabaseFactory[] factories) : base( - [ - ..factories, - () => database?.Invoke() - ?? (TDatabase)Activator.CreateInstance( - typeof(TDatabase), - new DatabaseOptions { - ForTesting = true, - } - )!, - ] - ) { + [ + ..factories, + () => database?.Invoke() + ?? (TDatabase)Activator.CreateInstance( + typeof(TDatabase), + new DatabaseOptions { + ForTesting = true, + } + )!, + ] +) { _database = (TDatabase)database?.Invoke()! ?? (TDatabase)Activator.CreateInstance( @@ -103,7 +102,7 @@ public DepotIntegrationTestsBase(DatabaseFactory? database = null, params Databa #region Abtraction /// - /// Creates a context [Entity] for testing data creation and assertion. + /// Creates an [Entity] for testing purposes. /// /// /// Random 16 length value for unique properties. @@ -111,7 +110,7 @@ public DepotIntegrationTestsBase(DatabaseFactory? database = null, params Databa /// /// A correctly built . /// - protected abstract TEntity EntityFactory(string Entropy); + protected abstract Task EntityFactory(string Entropy); #endregion @@ -174,14 +173,14 @@ protected async Task GeneratePointer(bool noStored = false) { #region Sampling /// - /// Creates a new instance based on the implementation. + /// Creates a new asynchronous instance based on the implementation. /// /// A new instance /// /// This instance is created but not stored in the database. /// - protected TEntity Sampling() { - return TestingStoreManager.RunEntityFactory(EntityFactory); + protected async Task Sampling() { + return await TestingStoreManager.RunEntityFactory(EntityFactory); } /// @@ -196,8 +195,12 @@ protected TEntity Sampling() { /// /// This instance collection is created but not stored in the database. /// - protected TEntity[] Sampling(int Count) { - return [.. Enumerable.Range(0, Count).Select(_ => TestingStoreManager.RunEntityFactory(EntityFactory))]; + protected async Task Sampling(int Count) { + List samples = []; + for (int i = 0; i < Count; i++) { + samples.Add(await TestingStoreManager.RunEntityFactory(EntityFactory)); + } + return samples.ToArray(); } #endregion @@ -210,10 +213,10 @@ protected TEntity[] Sampling(int Count) { /// [Fact(DisplayName = "[Create Single]: Entity created")] public virtual async Task Create_Single_Success() { - TEntity sample = Sampling(); + TEntity sample = await Sampling(); TEntity storedEntity = await _depot.Create(sample); - await CommitSampleEntities([storedEntity]); + await CommitSampleEntities(new IEntity[] { storedEntity }); Assert.Multiple( [ @@ -236,7 +239,7 @@ await Assert.ThrowsAnyAsync( /// [Fact(DisplayName = "[Create Batch]: Entities created")] public virtual async Task Create_Batch_Success() { - TEntity[] samples = Sampling(3); + TEntity[] samples = await Sampling(3); BatchOperationOutput qOut = await _depot.Create(samples); await CommitSampleEntities(samples); @@ -283,7 +286,7 @@ public virtual async Task Read_Single_ById_Success() { [Fact(DisplayName = "[Read Batch]: Entities read by (Id)")] public virtual async Task Read_Batch_ById_Sucess() { TEntity[] samples = await Store(20, EntityFactory); - long[] sampleIds = [.. samples.Select(i => i.Id)]; + long[] sampleIds = samples.Select(i => i.Id).ToArray(); BatchOperationOutput readEntities = await _depot.Read(sampleIds); Assert.Multiple( @@ -427,7 +430,7 @@ public virtual async Task Read_Batch_ByQueryAllMatches_Success() { /// [Fact(DisplayName = $"[Update Single]: Created when (Create) property enabled")] public virtual async Task Update_Single_OnCreateEnabled_Success() { - TEntity sample = TestingStoreManager.RunEntityFactory(EntityFactory); + TEntity sample = await TestingStoreManager.RunEntityFactory(EntityFactory); UpdateOutput updateOutput = await _depot.Update( new QueryInput> { @@ -459,7 +462,7 @@ public virtual async Task Update_Single_OnCreateEnabled_Success() { /// [Fact(DisplayName = $"[Update Single]: Throws exception (CREATE_DISABLED).")] public virtual async Task Update_Single_OnCreateDisabled_ErrorCreateDisabled() { - TEntity sample = TestingStoreManager.RunEntityFactory(EntityFactory); + TEntity sample = await TestingStoreManager.RunEntityFactory(EntityFactory); DepotError depotException = await Assert.ThrowsAsync>( async () => { @@ -482,7 +485,7 @@ public virtual async Task Update_Single_OnCreateDisabled_ErrorCreateDisabled() { /// [Fact(DisplayName = $"[Update Single]: Throws exception (UNFOUND)")] public virtual async Task Update_Single_ErrorUnfound() { - TEntity sample = TestingStoreManager.RunEntityFactory(EntityFactory); + TEntity sample = await TestingStoreManager.RunEntityFactory(EntityFactory); sample.Id = await GeneratePointer(); DepotError depotException = await Assert.ThrowsAsync>( @@ -536,10 +539,10 @@ public virtual async Task Delete_Single_ById_Success() { TEntity entity = await Store(EntityFactory); await _depot.Delete(entity.Id); - await CommitSampleEntities([]); + await CommitSampleEntities(Array.Empty()); - TEntity? searchedEntity = _database.Set().Find(entity.Id); - Assert.Null(searchedEntity); + List searchedEntity = await Get(new[] { entity }); + Assert.Empty(searchedEntity); } /// @@ -559,8 +562,11 @@ public virtual async Task Delete_Batch_ByQuery_Success() { ); await CommitSampleEntities([]); + List searchedEntity = await Get([entity]); + Assert.Multiple( [ + () => Assert.Empty(searchedEntity), () => Assert.False(deleteOutput.Failed), () => Assert.Empty(deleteOutput.Failures), () => Assert.NotEmpty(deleteOutput.Successes), diff --git a/CSM Database Testing/Abstractions/Bases/EntityIntegrationTestsBase.cs b/csharp_database_extension/CSharp Database Extension Testing/Abstractions/Bases/EntityIntegrationTestsBase.cs similarity index 86% rename from CSM Database Testing/Abstractions/Bases/EntityIntegrationTestsBase.cs rename to csharp_database_extension/CSharp Database Extension Testing/Abstractions/Bases/EntityIntegrationTestsBase.cs index 93a8b94..eed1a98 100644 --- a/CSM Database Testing/Abstractions/Bases/EntityIntegrationTestsBase.cs +++ b/csharp_database_extension/CSharp Database Extension Testing/Abstractions/Bases/EntityIntegrationTestsBase.cs @@ -1,7 +1,7 @@ -using CSM_Database_Core.Entities.Abstractions.Interfaces; -using CSM_Database_Core.Validation.Abstractions.Bases; +using CSharp_Database_Extension; +using CSharp_Database_Extension.Entities.Validation.Abstractions.Bases; -namespace CSM_Database_Testing.Abstractions.Bases; +namespace CSharp_Database_Extension_Testing.Abstractions.Bases; /// /// Represents an integration tests class for implementations. diff --git a/CSM Database Testing/Abstractions/Bases/TestingDataHandlerBase.cs b/csharp_database_extension/CSharp Database Extension Testing/Abstractions/Bases/TestingDataHandlerBase.cs similarity index 73% rename from CSM Database Testing/Abstractions/Bases/TestingDataHandlerBase.cs rename to csharp_database_extension/CSharp Database Extension Testing/Abstractions/Bases/TestingDataHandlerBase.cs index 0185827..9d502f7 100644 --- a/CSM Database Testing/Abstractions/Bases/TestingDataHandlerBase.cs +++ b/csharp_database_extension/CSharp Database Extension Testing/Abstractions/Bases/TestingDataHandlerBase.cs @@ -1,13 +1,13 @@ -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension; -using CSM_Database_Testing.Disposing; -using CSM_Database_Testing.Disposing.Abstractions.Bases; -using CSM_Database_Testing.Managers; +using CSharp_Database_Extension_Testing.Disposing; +using CSharp_Database_Extension_Testing.Disposing.Abstractions.Bases; +using CSharp_Database_Extension_Testing.Managers; -namespace CSM_Database_Testing.Abstractions.Bases; +namespace CSharp_Database_Extension_Testing.Abstractions.Bases; /// -/// Public Delegate for [Entity] factory [Quality] purposes. +/// Public Delegate for Asynchronous [Entity] factory [Quality] purposes. /// /// /// Type of the [Entity] to build. @@ -18,7 +18,7 @@ namespace CSM_Database_Testing.Abstractions.Bases; /// /// The Entity stored in the database. /// -public delegate TEntity EntityFactory(string Entropy) +public delegate Task EntityFactory(string Entropy) where TEntity : class, IEntity; /// @@ -65,10 +65,10 @@ public Task Store(TEntity2 entity) } /// - protected Task Store(EntityFactory entityFactory) + protected async Task Store(EntityFactory entityFactory) where TEntity2 : class, IEntity { - return _storeManager.Store(entityFactory); + return await _storeManager.Store(entityFactory); } /// @@ -77,4 +77,11 @@ protected async Task Store(int quantity, EntityFactory + protected async Task> Get(TEntity2[] entities) + where TEntity2 : class, IEntity, new() { + + return await _storeManager.Get(entities); + } } diff --git a/CSM Database Testing/Abstractions/Interfaces/ITestingDatabase.cs b/csharp_database_extension/CSharp Database Extension Testing/Abstractions/Interfaces/ITestingDatabase.cs similarity index 87% rename from CSM Database Testing/Abstractions/Interfaces/ITestingDatabase.cs rename to csharp_database_extension/CSharp Database Extension Testing/Abstractions/Interfaces/ITestingDatabase.cs index 21ca231..3ba5874 100644 --- a/CSM Database Testing/Abstractions/Interfaces/ITestingDatabase.cs +++ b/csharp_database_extension/CSharp Database Extension Testing/Abstractions/Interfaces/ITestingDatabase.cs @@ -1,4 +1,4 @@ -namespace CSM_Database_Testing.Abstractions.Interfaces; +namespace CSharp_Database_Extension_Testing.Abstractions.Interfaces; /// /// Interface Quality for [MigrationDatabases]. /// diff --git a/CSM Database Testing/BaseDraftUtils.cs b/csharp_database_extension/CSharp Database Extension Testing/BaseDraftUtils.cs similarity index 70% rename from CSM Database Testing/BaseDraftUtils.cs rename to csharp_database_extension/CSharp Database Extension Testing/BaseDraftUtils.cs index d2d762a..0e9483c 100644 --- a/CSM Database Testing/BaseDraftUtils.cs +++ b/csharp_database_extension/CSharp Database Extension Testing/BaseDraftUtils.cs @@ -1,8 +1,9 @@ -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -using CSM_Foundation_Core.Core.Utils; +using CSharp_Extension.Common.Utils; -namespace CSM_Database_Testing; +namespace CSharp_Database_Extension_Testing; /// /// Provide utils methods for entities bases drafting @@ -76,42 +77,21 @@ static public TPartnerScopeEntity PartnerScopeEntity(TPartn } /// - /// Drafts an instance with random data. + /// Drafts an instance with random data. /// - /// + /// /// Type of the entity to draft. /// /// /// Default values for the entity. /// /// - /// A drafted instance. - /// - static public TActivableEntity ActivableEntity(TActivableEntity? @ref = default) - where TActivableEntity : IActivableEntity, new() { - - @ref ??= Entity(@ref); - - return @ref; - } - - /// - /// Drafts a instance with random data. - /// - /// - /// Type of the entity to draft. - /// - /// - /// Default entity values. - /// - /// - /// A drafted instance. + /// A drafted instance. /// - static public TNamedEntity NamedEntity(TNamedEntity? @ref = default) - where TNamedEntity : INamedEntity, new() { - - @ref ??= Entity(@ref); + static public TEntity Entity(TEntity? @ref = default) + where TEntity : IEntity, new() { + @ref ??= new TEntity(); if (string.IsNullOrWhiteSpace(@ref.Name)) { @ref.Name = $"{Rnd}_name"; } @@ -122,24 +102,4 @@ static public TNamedEntity NamedEntity(TNamedEntity? @ref = defaul return @ref; } - - /// - /// Drafts an instance with random data. - /// - /// - /// Type of the entity to draft. - /// - /// - /// Default values for the entity. - /// - /// - /// A drafted instance. - /// - static public TEntity Entity(TEntity? @ref = default) - where TEntity : IEntity, new() { - - @ref ??= new TEntity(); - - return @ref; - } } diff --git a/CSM Database Testing/CSM Database Testing.csproj b/csharp_database_extension/CSharp Database Extension Testing/CSharp Database Extension Testing.csproj similarity index 54% rename from CSM Database Testing/CSM Database Testing.csproj rename to csharp_database_extension/CSharp Database Extension Testing/CSharp Database Extension Testing.csproj index 3fb0b0b..2af45b5 100644 --- a/CSM Database Testing/CSM Database Testing.csproj +++ b/csharp_database_extension/CSharp Database Extension Testing/CSharp Database Extension Testing.csproj @@ -1,34 +1,33 @@  + $(GitVersion) + CSharp.Database.Extension.Testing + CSharp_Database_Extension_Testing + https://github.com/Cosmos-CSM/csm_database + net10.0 - CSM_Database_Testing - CSM.Database.Testing - 8.0.0 + + true + true + A framework extension package for CSM extended utilities related with database testing, provide tools to properly and easily test organization database implementations and base expectations. + Renato Urrea Cosmos (CSM) - https://github.com/Cosmos-CSM/csm_database - enable + enable - true - CHANGELOG.md + Exe true false - Exe - true + enable - - - - - - + diff --git a/CSM Database Testing/Disposing/Abstractions/Bases/TestingDisposerBase.cs b/csharp_database_extension/CSharp Database Extension Testing/Disposing/Abstractions/Bases/TestingDisposerBase.cs similarity index 93% rename from CSM Database Testing/Disposing/Abstractions/Bases/TestingDisposerBase.cs rename to csharp_database_extension/CSharp Database Extension Testing/Disposing/Abstractions/Bases/TestingDisposerBase.cs index b04a070..f292403 100644 --- a/CSM Database Testing/Disposing/Abstractions/Bases/TestingDisposerBase.cs +++ b/csharp_database_extension/CSharp Database Extension Testing/Disposing/Abstractions/Bases/TestingDisposerBase.cs @@ -1,13 +1,14 @@ using System.Collections.Concurrent; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -using CSM_Database_Testing.Disposing.Abstractions.Interfaces; +using CSharp_Database_Extension_Testing.Disposing.Abstractions.Interfaces; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; -namespace CSM_Database_Testing.Disposing.Abstractions.Bases; +namespace CSharp_Database_Extension_Testing.Disposing.Abstractions.Bases; /// /// Database context factory delegate. diff --git a/csharp_database_extension/CSharp Database Extension Testing/Disposing/Abstractions/Interfaces/ITestingDisposer.cs b/csharp_database_extension/CSharp Database Extension Testing/Disposing/Abstractions/Interfaces/ITestingDisposer.cs new file mode 100644 index 0000000..ba1f25f --- /dev/null +++ b/csharp_database_extension/CSharp Database Extension Testing/Disposing/Abstractions/Interfaces/ITestingDisposer.cs @@ -0,0 +1,12 @@ +using CSharp_Database_Extension; + +using CSharp_Extension.Common.Abstractions.Interfaces; + +namespace CSharp_Database_Extension_Testing.Disposing.Abstractions.Interfaces; + +/// +/// Represents a testing data disposer context handler. +/// +public interface ITestingDisposer + : IDisposer { +} diff --git a/CSM Database Testing/Disposing/TestingDisposer.cs b/csharp_database_extension/CSharp Database Extension Testing/Disposing/TestingDisposer.cs similarity index 76% rename from CSM Database Testing/Disposing/TestingDisposer.cs rename to csharp_database_extension/CSharp Database Extension Testing/Disposing/TestingDisposer.cs index bc98167..2d38cdf 100644 --- a/CSM Database Testing/Disposing/TestingDisposer.cs +++ b/csharp_database_extension/CSharp Database Extension Testing/Disposing/TestingDisposer.cs @@ -1,6 +1,6 @@ -using CSM_Database_Testing.Disposing.Abstractions.Bases; +using CSharp_Database_Extension_Testing.Disposing.Abstractions.Bases; -namespace CSM_Database_Testing.Disposing; +namespace CSharp_Database_Extension_Testing.Disposing; /// public class TestingDisposer diff --git a/CSM Database Testing/Managers/TestingStoreManager.cs b/csharp_database_extension/CSharp Database Extension Testing/Managers/TestingStoreManager.cs similarity index 77% rename from CSM Database Testing/Managers/TestingStoreManager.cs rename to csharp_database_extension/CSharp Database Extension Testing/Managers/TestingStoreManager.cs index 3d78b76..e2c6efa 100644 --- a/CSM Database Testing/Managers/TestingStoreManager.cs +++ b/csharp_database_extension/CSharp Database Extension Testing/Managers/TestingStoreManager.cs @@ -1,16 +1,16 @@ -using CSM_Database_Core.Core.Utils; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension; +using CSharp_Database_Extension.Common.Utils; -using CSM_Database_Testing.Abstractions.Bases; -using CSM_Database_Testing.Disposing; -using CSM_Database_Testing.Disposing.Abstractions.Bases; -using CSM_Database_Testing.Disposing.Abstractions.Interfaces; +using CSharp_Database_Extension_Testing.Abstractions.Bases; +using CSharp_Database_Extension_Testing.Disposing; +using CSharp_Database_Extension_Testing.Disposing.Abstractions.Bases; +using CSharp_Database_Extension_Testing.Disposing.Abstractions.Interfaces; -using CSM_Foundation_Core.Core.Utils; +using CSharp_Extension.Common.Utils; using Microsoft.EntityFrameworkCore; -namespace CSM_Database_Testing.Managers; +namespace CSharp_Database_Extension_Testing.Managers; /// /// Represents a testing data storing methods manager. @@ -127,7 +127,7 @@ await DatabaseUtils.SanitizeEntity(db, entity) public async Task Store(EntityFactory entityFactory) where TEntity2 : class, IEntity { - TEntity2 toStore = RunEntityFactory(entityFactory); + TEntity2 toStore = await RunEntityFactory(entityFactory); toStore = await Store(toStore); return toStore; @@ -156,7 +156,7 @@ public async Task Store(int quantity, EntityFactory Store(int quantity, EntityFactory /// The generated [Entity] object. /// - public static TEntity2 RunEntityFactory(EntityFactory factory) + public static async Task RunEntityFactory(EntityFactory factory) where TEntity2 : class, IEntity { - return factory(RandomUtils.String(16)); + return await factory(RandomUtils.String(16)); } /// @@ -203,4 +203,30 @@ DbContext GetDatabase(Type databaseType) { ? throw new Exception($"No factory subscribed for [({databaseType.Name})]") : factory(); } + + /// + /// Retrieves the stored instances that match the given . + /// + /// + /// Type of the to retrieve. + /// + /// + /// Collection of instances to look up. + /// + /// + /// A list of instances whose is contained in . + /// Only the IDs that exist in the database are included. + /// + public async Task> Get(TEntity2[] entities) + where TEntity2 : class, IEntity, new() { + + using DbContext database = GetDatabase(new TEntity2().Database); + + object[] ids = [.. entities.Select(entity => entity.Id)]; + List found = await database.Set() + .Where(entity => ids.Contains(entity.Id)) + .ToListAsync(); + + return found; + } } diff --git a/csharp_database_extension/CSharp Database Extension Testing/release-notes/v0.0.1-beta.md b/csharp_database_extension/CSharp Database Extension Testing/release-notes/v0.0.1-beta.md new file mode 100644 index 0000000..0f1942b --- /dev/null +++ b/csharp_database_extension/CSharp Database Extension Testing/release-notes/v0.0.1-beta.md @@ -0,0 +1,153 @@ +## Release 0.0.1-beta + +### PR Summary + +**Title:** vbump: 0.0.1 beta + +**Author:** @RMotive + +**Description:** + +No description provided. + +**Labels:** None + +### Changes + +**Files modified:** +- .gitattributes +- .github/workflows/cd-1.yml +- .github/workflows/ci.yaml +- CSM Database Core/Abstractions/Interfaces/IDatabase.cs +- CSM Database Core/CHANGELOG.md +- CSM Database Core/Core/Attributes/Abstractions/Bases/RelationAttributeBase.cs +- CSM Database Core/Core/Attributes/Abstractions/Interfaces/IRelationAttribute.cs +- CSM Database Core/Entities/Abstractions/Bases/ActivableEntityBase.cs +- CSM Database Core/Entities/Abstractions/Bases/EntityBase.cs +- CSM Database Core/Entities/Abstractions/Bases/NamedEntityBase.cs +- CSM Database Core/Entities/Abstractions/Interfaces/IActivableEntity.cs +- CSM Database Core/Entities/Abstractions/Interfaces/IEntity.cs +- CSM Database Core/Entities/Abstractions/Interfaces/INamedEntity.cs +- CSM Database Testing/CHANGELOG.md +- CSM Database Testing/Disposing/Abstractions/Interfaces/ITestingDisposer.cs +- DatabaseProxy/Migrations/20260401220538_Init Db.Designer.cs +- DatabaseProxy/Migrations/20260401220538_Init Db.cs +- DatabaseProxy/Migrations/20260401221950_Init_Db_2.Designer.cs +- DatabaseProxy/Migrations/20260401221950_Init_Db_2.cs +- DatabaseProxy/Migrations/20260506231958_added_autoloading.Designer.cs +- DatabaseProxy/Migrations/20260506231958_added_autoloading.cs +- DatabaseProxy/Migrations/20260506232702_added_renamings.Designer.cs +- DatabaseProxy/Migrations/20260506232702_added_renamings.cs +- DatabaseProxy/Migrations/20260506232938_added_attributes.Designer.cs +- DatabaseProxy/Migrations/20260506232938_added_attributes.cs +- DatabaseProxy/Migrations/20260506233726_added_attributes_2.Designer.cs +- DatabaseProxy/Migrations/20260506233726_added_attributes_2.cs +- DatabaseProxy/Migrations/20260507000230_standarized db for proxies.Designer.cs +- DatabaseProxy/Migrations/20260507000230_standarized db for proxies.cs +- DatabaseProxy/Migrations/20260507000851_standarized db for proxies 2.Designer.cs + +**Commits:** +- forgot include +- Issue #41 - Adding async support for testing methods +- Issue #44 - Adding get method in [TestingStoreManager] +- removing unnecesary sync methods in csm database testing +- pull dev changes +- testing methods optimizations +- Summary definitions changes +- Merge pull request #45 from Cosmos-CSM/dev@issue_41_43 +- +- Dev@issue_41_43_44 --> Dev +- file structuring +- organizing solution +- Checking project adjustments and content +- testing and main project building +- integration tests added pending to check +- structuring multi providers +- finishing standarization and ready to go first version +- added unit tests project, correected ci workflow +- updating CI workflow +- fixing CI +- updating cd workflows +- pusing eol validation +- trying something else +- adding git attributes +- checking now +- changing approach +- applying checks +- trying again +- updating workflow +- aother update +- another try +- last try + +### Notes + +- Generated from PR metadata: title, body, labels, files, commits. + + +- added publisihment (Juan Renato Urrea Ortiz) +- fixed token (Juan Renato Urrea Ortiz) +- fixing generation (Juan Renato Urrea Ortiz) +- Merge branch 'vbump_0.0.1-beta' of https://github.com/Cosmos-CSM/fe_csharp_database into vbump_0.0.1-beta (Juan Renato Urrea Ortiz) +- trying new release generation (Juan Renato Urrea Ortiz) +- Generated vdocs. (github-actions) +- Merge branch 'vbump_0.0.1-beta' of https://github.com/Cosmos-CSM/fe_csharp_database into vbump_0.0.1-beta (Juan Renato Urrea Ortiz) +- preventing looping (Juan Renato Urrea Ortiz) +- Generated vdocs. (github-actions) +- Generated vdocs. (github-actions) +- Generated vdocs. (github-actions) +- fixing version check (Juan Renato Urrea Ortiz) +- fixing error (Juan Renato Urrea Ortiz) +- Merge branch 'vbump_0.0.1-beta' of https://github.com/Cosmos-CSM/fe_csharp_database into vbump_0.0.1-beta (Juan Renato Urrea Ortiz) +- adding a branch check (Juan Renato Urrea Ortiz) +- Generated vdocs. (github-actions) +- Generated vdocs. (github-actions) +- Generated vdocs. (github-actions) +- fixed ident (Juan Renato Urrea Ortiz) +- added message (Juan Renato Urrea Ortiz) +- fixed all syntax (Juan Renato Urrea Ortiz) +- fixing arguments (Juan Renato Urrea Ortiz) +- fixed syntax (Juan Renato Urrea Ortiz) +- fixed syntax error (Juan Renato Urrea Ortiz) +- testing new version (Juan Renato Urrea Ortiz) +- trying another apporach (Juan Renato Urrea Ortiz) +- trying single line approach (Juan Renato Urrea Ortiz) +- corrected a workflow var (Juan Renato Urrea Ortiz) +- testing workflow to auto-generate release docs (Juan Renato Urrea Ortiz) +- Merge branch 'main' into dev (Renato Urrea) +- Merge branch 'dev' of https://github.com/Cosmos-CSM/fe_csharp_database into dev (Juan Renato Urrea Ortiz) +- adding package metadata and bump checker (Juan Renato Urrea Ortiz) +- Merge branch 'main' into dev (Renato Urrea) +- removing cd workflows (Juan Renato Urrea Ortiz) +- Merge pull request #47 from Cosmos-CSM/46-standarize-repository (Renato Urrea) +- adding nuget source (Juan Renato Urrea Ortiz) +- last try (Juan Renato Urrea Ortiz) +- another try (Juan Renato Urrea Ortiz) +- aother update (Juan Renato Urrea Ortiz) +- updating workflow (Juan Renato Urrea Ortiz) +- trying again (Juan Renato Urrea Ortiz) +- applying checks (Juan Renato Urrea Ortiz) +- changing approach (Juan Renato Urrea Ortiz) +- checking now (Juan Renato Urrea Ortiz) +- adding git attributes (Juan Renato Urrea Ortiz) +- trying something else (Juan Renato Urrea Ortiz) +- pusing eol validation (Juan Renato Urrea Ortiz) +- updating cd workflows (Juan Renato Urrea Ortiz) +- fixing CI (Juan Renato Urrea Ortiz) +- updating CI workflow (Juan Renato Urrea Ortiz) +- added unit tests project, correected ci workflow (Juan Renato Urrea Ortiz) +- finishing standarization and ready to go first version (Juan Renato Urrea Ortiz) +- structuring multi providers (Juan Renato Urrea Ortiz) +- integration tests added pending to check (Renato Urrea) +- testing and main project building (Renato Urrea) +- Checking project adjustments and content (Renato Urrea) +- organizing solution (Juan Renato Urrea Ortiz) +- file structuring (Juan Renato Urrea Ortiz) +- Merge pull request #45 from Cosmos-CSM/dev@issue_41_43 (Renato Urrea) +- Summary definitions changes (jr110) +- testing methods optimizations (jr110) +- pull dev changes (jr110) +- removing unnecesary sync methods in csm database testing (jr110) +- Issue #44 - Adding get method in [TestingStoreManager] (jr110) +- Issue #41 - Adding async support for testing methods (jr110) +- forgot include (Juan Renato Urrea Ortiz) \ No newline at end of file diff --git a/CSM Database.sln b/csharp_database_extension/CSharp Database Extension.sln similarity index 54% rename from CSM Database.sln rename to csharp_database_extension/CSharp Database Extension.sln index aa09627..fed831b 100644 --- a/CSM Database.sln +++ b/csharp_database_extension/CSharp Database Extension.sln @@ -10,15 +10,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution local.integration_tests.runsettings = local.integration_tests.runsettings EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSM Database Core", "CSM Database Core\CSM Database Core.csproj", "{4A3C8AEE-DF2B-0967-7D71-5B7C61239D19}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharp Database Extension", "CSharp Database Extension\CSharp Database Extension.csproj", "{72B5B574-C82D-1E32-04E2-C221BE46753D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSM Database Testing", "CSM Database Testing\CSM Database Testing.csproj", "{82BDDC7B-DFF5-141A-9515-08F20D497D11}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharp Database Extension Testing", "CSharp Database Extension Testing\CSharp Database Extension Testing.csproj", "{0EAC75F4-83B9-73B2-74CF-F6D4BBD3BEBF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unit Tests", "Unit Tests\Unit Tests.csproj", "{CBAAFF94-19D9-CA27-EB09-AC83990DFBC8}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration Tests", "Integration Tests\Integration Tests.csproj", "{91408A5A-3EBE-2556-7CBA-4031BA06CE0B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration Tests", "Integration Tests\Integration Tests.csproj", "{DEE0BFEC-6ED6-42CD-8F60-D3C2823DDDDA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseProxy", "DatabaseProxy\DatabaseProxy.csproj", "{5FBB0C80-E310-CB96-56E1-AF38D8BA8F32}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseProxy", "DatabaseProxy\DatabaseProxy.csproj", "{5FFED488-8120-4A2C-BE06-A8E1D5E9D6E6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unit Tests", "Unit Tests\Unit Tests.csproj", "{CBAAFF94-19D9-CA27-EB09-AC83990DFBC8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -26,26 +26,26 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4A3C8AEE-DF2B-0967-7D71-5B7C61239D19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4A3C8AEE-DF2B-0967-7D71-5B7C61239D19}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4A3C8AEE-DF2B-0967-7D71-5B7C61239D19}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4A3C8AEE-DF2B-0967-7D71-5B7C61239D19}.Release|Any CPU.Build.0 = Release|Any CPU - {82BDDC7B-DFF5-141A-9515-08F20D497D11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {82BDDC7B-DFF5-141A-9515-08F20D497D11}.Debug|Any CPU.Build.0 = Debug|Any CPU - {82BDDC7B-DFF5-141A-9515-08F20D497D11}.Release|Any CPU.ActiveCfg = Release|Any CPU - {82BDDC7B-DFF5-141A-9515-08F20D497D11}.Release|Any CPU.Build.0 = Release|Any CPU + {72B5B574-C82D-1E32-04E2-C221BE46753D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {72B5B574-C82D-1E32-04E2-C221BE46753D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {72B5B574-C82D-1E32-04E2-C221BE46753D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {72B5B574-C82D-1E32-04E2-C221BE46753D}.Release|Any CPU.Build.0 = Release|Any CPU + {0EAC75F4-83B9-73B2-74CF-F6D4BBD3BEBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0EAC75F4-83B9-73B2-74CF-F6D4BBD3BEBF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0EAC75F4-83B9-73B2-74CF-F6D4BBD3BEBF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0EAC75F4-83B9-73B2-74CF-F6D4BBD3BEBF}.Release|Any CPU.Build.0 = Release|Any CPU + {91408A5A-3EBE-2556-7CBA-4031BA06CE0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {91408A5A-3EBE-2556-7CBA-4031BA06CE0B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {91408A5A-3EBE-2556-7CBA-4031BA06CE0B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {91408A5A-3EBE-2556-7CBA-4031BA06CE0B}.Release|Any CPU.Build.0 = Release|Any CPU + {5FBB0C80-E310-CB96-56E1-AF38D8BA8F32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5FBB0C80-E310-CB96-56E1-AF38D8BA8F32}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5FBB0C80-E310-CB96-56E1-AF38D8BA8F32}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5FBB0C80-E310-CB96-56E1-AF38D8BA8F32}.Release|Any CPU.Build.0 = Release|Any CPU {CBAAFF94-19D9-CA27-EB09-AC83990DFBC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CBAAFF94-19D9-CA27-EB09-AC83990DFBC8}.Debug|Any CPU.Build.0 = Debug|Any CPU {CBAAFF94-19D9-CA27-EB09-AC83990DFBC8}.Release|Any CPU.ActiveCfg = Release|Any CPU {CBAAFF94-19D9-CA27-EB09-AC83990DFBC8}.Release|Any CPU.Build.0 = Release|Any CPU - {DEE0BFEC-6ED6-42CD-8F60-D3C2823DDDDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DEE0BFEC-6ED6-42CD-8F60-D3C2823DDDDA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DEE0BFEC-6ED6-42CD-8F60-D3C2823DDDDA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DEE0BFEC-6ED6-42CD-8F60-D3C2823DDDDA}.Release|Any CPU.Build.0 = Release|Any CPU - {5FFED488-8120-4A2C-BE06-A8E1D5E9D6E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5FFED488-8120-4A2C-BE06-A8E1D5E9D6E6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5FFED488-8120-4A2C-BE06-A8E1D5E9D6E6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5FFED488-8120-4A2C-BE06-A8E1D5E9D6E6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CSM Database Core/Abstractions/Bases/DatabaseBase.cs b/csharp_database_extension/CSharp Database Extension/Abstractions/Bases/DatabaseBase.cs similarity index 55% rename from CSM Database Core/Abstractions/Bases/DatabaseBase.cs rename to csharp_database_extension/CSharp Database Extension/Abstractions/Bases/DatabaseBase.cs index e91c45c..eb33e15 100644 --- a/CSM Database Core/Abstractions/Bases/DatabaseBase.cs +++ b/csharp_database_extension/CSharp Database Extension/Abstractions/Bases/DatabaseBase.cs @@ -1,159 +1,65 @@ using System.Reflection; -using CSM_Database_Core.Abstractions.Interfaces; -using CSM_Database_Core.Core.Errors; -using CSM_Database_Core.Core.Models; -using CSM_Database_Core.Core.Utils; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Abstractions.Interfaces; +using CSharp_Database_Extension.Common.Enums; +using CSharp_Database_Extension.Common.Errors; +using CSharp_Database_Extension.Common.Models; +using CSharp_Database_Extension.Common.Utils; +using CSharp_Database_Extension.Entities.Validation.Models; -using CSM_Foundation_Core.Core.Utils; +using CSharp_Extension.Common.Utils; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace CSM_Database_Core; +namespace CSharp_Database_Extension; /// -/// Represents a CSM Database, wich configures and handles data management along business entities and -/// data persistence. +/// Represents a Database Model. /// -/// -/// implementation of the database handler. +/// +/// Type of the database model. /// -public abstract partial class DatabaseBase +public abstract partial class DatabaseBase : DbContext, IDatabase - where TDatabases : DbContext { + where TDatabase : DbContext { /// - public virtual string Sign { get; protected set; } = "DBSign"; + public virtual string Signature { get; protected set; } = ""; + + /// + public virtual DatabaseProviders Provider { get; protected set; } = DatabaseProviders.PostgreSQL; /// - /// Database context options. + /// Database model options. /// - public DatabaseOptions DatabaseOptions { get; init; } + public DatabaseOptions Options { get; init; } /// /// Creates a new instance. /// public DatabaseBase() { - DatabaseOptions = new DatabaseOptions(); - BuildOptions(); + Options = new DatabaseOptions(); + CompleteOptions(); } /// /// Creates a new instance. /// /// - /// Database context options. + /// EF Database context options. /// - public DatabaseBase(DatabaseOptions databaseOptions) + public DatabaseBase(DatabaseOptions databaseOptions) : base(databaseOptions.DbContextOptions ?? new()) { - DatabaseOptions = databaseOptions; - - BuildOptions(); - } - - /// - /// Validates dependencies and generates required ones. - /// - /// - /// Important process, is required to be called in each constructor. - /// - void BuildOptions() { - DatabaseOptions.Sign ??= Sign; - - DatabaseOptions.ConnectionOptions ??= DatabaseUtils.GetConnectionOptions(Sign, DatabaseOptions.ForTesting); - } - - /// - /// Validates if all the are assuring contains the correct methods needed. - /// - /// - /// Validated entity types to be handled. - /// - protected EntityBase[] GetSetsDefinitions() { - Type databaseType = GetType(); - - List entityModels = []; - IEnumerable dbSets = databaseType - .GetProperties() - .Where( - (propInfo) => { - Type propType = propInfo.PropertyType; - - return propType.IsGenericType && propType.GetGenericTypeDefinition() == typeof(DbSet<>); - } - ); - - foreach (PropertyInfo dbSet in dbSets) { - Type generic = dbSet.PropertyType.GetGenericArguments()[0] - ?? throw new DatabaseError( - DatabaseErrorEvents.WRONG_DBSET_ENTITY, - new Dictionary { - { "DbSet", dbSet.Name } - } - ); - - if (!generic.IsInterface) { - EntityBase instance = (EntityBase)Activator.CreateInstance(generic)!; - entityModels.Add(instance); - continue; - } - } - - return [.. entityModels]; - } - - /// - /// Evaluates if are correctly configured and translated to the internal framework handler. - /// - bool ValidateSetsDefinitions(bool strict = true) { - - bool logsOn = DatabaseOptions.EnableLogging; - EntityBase[] sets = GetSetsDefinitions(); - - if (logsOn) { - ConsoleUtils.Announce( - $"[{GetType().Name}] Validatig Sets...", - new() { - { "Count", sets.Length } - } - ); - } - - Exception[] evResults = []; - foreach (EntityBase set in sets) { - Exception[] result = set.EvaluateDefinition(); - if (result.Length > 0 && logsOn) { - ConsoleUtils.Warning( - "Wrong [DbSet] definition", - new() { - { "Set", set.GetType().Name }, - { "Exceptions", result }, - } - ); - } - - evResults = [.. evResults, .. result]; - } - - if (evResults.Length > 0) { - if (strict) - throw new Exception("Database [DbSet] definition failures"); - - return false; - } + Options = databaseOptions; - if (logsOn) - ConsoleUtils.Success($"[{GetType().Name}] Set validation succeeded"); - - return true; + CompleteOptions(); } /// public bool Validate(bool strict = true) { - bool logsOn = DatabaseOptions.EnableLogging; + bool logsOn = Options.EnableLogging; if (logsOn) { ConsoleUtils.Announce( @@ -177,7 +83,7 @@ public bool Validate(bool strict = true) { return false; } - return ValidateSetsDefinitions(strict); + return ValidateEntityModels(strict); } try { @@ -193,36 +99,77 @@ public bool Validate(bool strict = true) { } /// - /// Designs the current instance for the given , overriding - /// the current behavior. + /// Gets database entity models. /// - /// - /// Entity instance being designed. - /// - /// - /// Global database model builder instance. - /// - protected virtual void DesignEntity(EntityBase entity, EntityTypeBuilder mBuilder) { } + /// + /// Database entity instances as models. + /// + protected EntityBase[] GetEntityModels() { + Type dbType = GetType(); - /// - /// Designs the current instance for the database, overriding the current behavior. - /// - /// - /// Global database model builder instance. - /// - protected virtual void DesignDatabase(ModelBuilder mBuilder) { } + List entityModels = []; + IEnumerable dbSets = dbType + .GetProperties() + .Where( + (propInfo) => { + Type propType = propInfo.PropertyType; + + return propType.IsGenericType && propType.GetGenericTypeDefinition() == typeof(DbSet<>); + } + ); + + foreach (PropertyInfo dbSet in dbSets) { + Type generic = dbSet.PropertyType.GetGenericArguments()[0] + ?? throw new DatabaseError( + DatabaseErrorEvents.WRONG_DBSET_ENTITY, + new Dictionary { + { "DbSet", dbSet.Name } + } + ); + + if (!generic.IsInterface) { + EntityBase instance = (EntityBase)Activator.CreateInstance(generic)!; + entityModels.Add(instance); + continue; + } + } + + return [.. entityModels]; + } /// protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - string connectionString = DatabaseOptions.ConnectionOptions!.ConnectionString; - optionsBuilder.UseSqlServer(connectionString); + string connectionString = Options.ConnectionOptions!.ConnectionString; + + switch (Options.Provider) { + case DatabaseProviders.SQLServer: + optionsBuilder.UseSqlServer( + connectionString, + builder => { + if (Options.Migrations is not null) { + builder.MigrationsAssembly(Options.Migrations); + } + } + ); + break; + case DatabaseProviders.PostgreSQL: + optionsBuilder.UseNpgsql( + connectionString, + builder => { + if(Options.Migrations is not null) { + builder.MigrationsAssembly(Options.Migrations); + } + } + ); + break; + } // We catch when the execution context is an Entity Framework design runtime. if (AppDomain.CurrentDomain.FriendlyName.Contains("ef")) { string envValue = SystemUtils.GetVar("ASPNETCORE_ENVIRONMENT") ?? SystemUtils.GetVar("DOTNET_ENVIRONMENT") ?? "---"; - if (DatabaseOptions.EnableLogging) { + if (Options.EnableLogging) { ConsoleUtils.Warning( $"Running EF Design Time Execution", new Dictionary { @@ -253,23 +200,16 @@ protected override void OnModelCreating(ModelBuilder mBuilder) { } } - EntityBase[] sets = GetSetsDefinitions(); + EntityBase[] entityModels = GetEntityModels(); - foreach (EntityBase entity in sets) { - Type setType = entity.GetType(); + foreach (EntityBase entity in entityModels) { + Type entityModelType = entity.GetType(); mBuilder.Entity( - setType, + entityModelType, (etBuilder) => { - etBuilder.HasKey(nameof(IEntity.Id)); - etBuilder.Property(nameof(IEntity.Id)).IsRequired(); - - DesignEntityInterfacing(etBuilder, entity); + DesignEntityModelInterfaces(etBuilder, entity); DesignEntity(entity, etBuilder); - etBuilder.Property(nameof(IEntity.Timestamp)) - .HasColumnType("datetime2(7)") - .HasDefaultValueSql("GETUTCDATE()"); - entity.DesignEntity(etBuilder); } ); @@ -278,6 +218,92 @@ protected override void OnModelCreating(ModelBuilder mBuilder) { base.OnModelCreating(mBuilder); } + /// + /// Designs the database entity models type, in order to be translated to database provider language. + /// + /// + /// Entity Model to be designed. + /// + /// + /// Global database entity model builder. + /// + protected virtual void DesignEntity(EntityBase entity, EntityTypeBuilder mBuilder) { } + + /// + /// Designs the current instance for the database, overriding the current behavior. + /// + /// + /// Global database model builder instance. + /// + protected virtual void DesignDatabase(ModelBuilder mBuilder) { } + + /// + /// Validate database entity models. + /// + /// + /// Whether the engines should be stopped on invalid entities. + /// + bool ValidateEntityModels(bool strict = true) { + + bool logsOn = Options.EnableLogging; + EntityBase[] defs = GetEntityModels(); + + if (logsOn) { + ConsoleUtils.Announce( + $"[{GetType().Name}] Validatig Entity Models...", + new() { + { "Count", defs.Length } + } + ); + } + + EntityEvaluationFailure[] evResults = []; + foreach (EntityBase entity in defs) { + EntityEvaluationFailure[] modelFailures = entity.EvaluateModel(); + if (modelFailures.Length > 0 && logsOn) { + ConsoleUtils.Warning( + "Wrong [Entity Model] definition", + new() { + { "Entity Model", entity.GetType().Name }, + { "Result", modelFailures }, + } + ); + } + + evResults = [.. evResults, .. modelFailures]; + } + + if (evResults.Length > 0) { + if (strict) + throw new Exception("Database [Entity Models] validation failed"); + + return false; + } + + if (logsOn) + ConsoleUtils.Success($"[{GetType().Name}] Set validation succeeded"); + + return true; + } + + /// + /// Completes missing values that are auto-loaded + /// by system properties or values calculated at runtime. + /// + /// + /// Important process, is required to be called in each constructor of this class. + /// + void CompleteOptions() { + Options.Signature ??= Signature; + + // When current options provider is the default one. + if (Options.Provider == DatabaseProviders.PostgreSQL) { + Options.Provider = Provider; + } + + Options.ConnectionOptions ??= DatabaseUtils.GetConnectionOptions(Signature, Options.ForTesting); + } + /// /// Design business interfacing for business entities with their defined properties and behavior. /// @@ -287,32 +313,33 @@ protected override void OnModelCreating(ModelBuilder mBuilder) { /// /// Entity instance modeled. /// - static void DesignEntityInterfacing(EntityTypeBuilder etBuilder, EntityBase entity) { - if (entity is INamedEntity) { - PropertyInfo nameProperty = entity.GetProperty(nameof(INamedEntity.Name)); - PropertyInfo descriptionProperty = entity.GetProperty(nameof(INamedEntity.Description)); - - etBuilder - .HasIndex(nameProperty.Name) - .IsUnique(); - etBuilder - .Property(nameProperty.Name) - .HasMaxLength(100).IsRequired(); - - etBuilder - .Property(descriptionProperty.Name); - } - - if (entity is IActivableEntity) { - PropertyInfo isEnabledProperty = entity.GetProperty(nameof(IActivableEntity.IsEnabled)); - - etBuilder.Property(isEnabledProperty.Name) - .IsRequired(); - } + static void DesignEntityModelInterfaces(EntityTypeBuilder etBuilder, EntityBase entity) { + etBuilder.HasKey(nameof(IEntity.Id)); + etBuilder.Property(nameof(IEntity.Id)) + .IsRequired(); + + PropertyInfo nameProperty = entity.GetProperty(nameof(IEntity.Name)); + PropertyInfo descriptionProperty = entity.GetProperty(nameof(IEntity.Description)); + + etBuilder + .HasIndex(nameProperty.Name) + .IsUnique(); + etBuilder + .Property(nameProperty.Name) + .HasMaxLength(200) + .IsRequired(); + + etBuilder + .Property(descriptionProperty.Name); + + etBuilder.Property(nameof(IEntity.Timestamp)) + .HasColumnType("datetime2(7)") + .HasDefaultValueSql("GETUTCDATE()") + .IsRowVersion(); } } -/// +/// public abstract partial class EntityBase { /// @@ -323,7 +350,7 @@ public abstract partial class EntityBase { /// Proxy object to configure Entity Model to Entity Framework Core. /// /// - /// Don't describe properties they are being auto-described by the [CSM] engine, , and . + /// Don't describe properties they are being auto-described by the [CSM] engine, , and . /// protected internal virtual void DesignEntity(EntityTypeBuilder etBuilder) { } } \ No newline at end of file diff --git a/CSM Database Core/Abstractions/Bases/DatabaseDesignerBase.cs b/csharp_database_extension/CSharp Database Extension/Abstractions/Bases/DatabaseDesignerBase.cs similarity index 84% rename from CSM Database Core/Abstractions/Bases/DatabaseDesignerBase.cs rename to csharp_database_extension/CSharp Database Extension/Abstractions/Bases/DatabaseDesignerBase.cs index 0321bef..f90cf8f 100644 --- a/CSM Database Core/Abstractions/Bases/DatabaseDesignerBase.cs +++ b/csharp_database_extension/CSharp Database Extension/Abstractions/Bases/DatabaseDesignerBase.cs @@ -1,11 +1,11 @@ -using CSM_Database_Core.Abstractions.Interfaces; +using CSharp_Database_Extension.Abstractions.Interfaces; -using CSM_Foundation_Core.Core.Utils; +using CSharp_Extension.Common.Utils; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; -namespace CSM_Database_Core.Abstractions.Bases; +namespace CSharp_Database_Extension.Abstractions.Bases; /// /// Represents a design time factory. diff --git a/csharp_database_extension/CSharp Database Extension/Abstractions/Interfaces/IDatabase.cs b/csharp_database_extension/CSharp Database Extension/Abstractions/Interfaces/IDatabase.cs new file mode 100644 index 0000000..58741a1 --- /dev/null +++ b/csharp_database_extension/CSharp Database Extension/Abstractions/Interfaces/IDatabase.cs @@ -0,0 +1,30 @@ +using CSharp_Database_Extension.Common.Enums; + +namespace CSharp_Database_Extension.Abstractions.Interfaces; + +/// +/// Represents a Database model. +/// +public interface IDatabase { + + /// + /// Database signature, used to be identified along ecosystems. + /// + string Signature { get; } + + /// + /// Database provider type. + /// + DatabaseProviders Provider { get; } + + /// + /// Validates database connection and configuration health. + /// + /// + /// Whether the validation process is strict, breaking execution on error. + /// + /// + /// Whether the validation process was sucessful or not. + /// + bool Validate(bool strict = true); +} \ No newline at end of file diff --git a/csharp_database_extension/CSharp Database Extension/CSharp Database Extension.csproj b/csharp_database_extension/CSharp Database Extension/CSharp Database Extension.csproj new file mode 100644 index 0000000..35b875f --- /dev/null +++ b/csharp_database_extension/CSharp Database Extension/CSharp Database Extension.csproj @@ -0,0 +1,31 @@ + + + + $(GitVersion) + CSharp.Database.Extension + CSharp_Database_Extension + https://github.com/Cosmos-CSM/csm_database + + net10.0 + + true + true + A framework extension package for CSM extended utilities related with database management, provide tools to configure easily database models and standard through organization creations. + + Renato Urrea + Cosmos (CSM) + + enable + true + enable + + + + + + + + + + + diff --git a/csharp_database_extension/CSharp Database Extension/Common/Attributes/Abstractions/Bases/RelationAttributeBase.cs b/csharp_database_extension/CSharp Database Extension/Common/Attributes/Abstractions/Bases/RelationAttributeBase.cs new file mode 100644 index 0000000..3f81819 --- /dev/null +++ b/csharp_database_extension/CSharp Database Extension/Common/Attributes/Abstractions/Bases/RelationAttributeBase.cs @@ -0,0 +1,28 @@ +using CSharp_Database_Extension.Common.Attributes.Abstractions.Interfaces; + +namespace CSharp_Database_Extension.Common.Attributes.Abstractions.Bases; + +/// +public abstract class RelationAttributeBase + : Attribute, IRelationAttribute { + + /// + public string? Name { get; set; } + + /// + public bool IsCrossDatabase { get; set; } + + /// + /// Creates a new instance. + /// + /// + /// Relation's name. + /// + /// + /// Whether the relation references an entity on a different database. + /// + public RelationAttributeBase(string? name = null, bool isCrossDatabase = false) { + Name = name; + IsCrossDatabase = isCrossDatabase; + } +} diff --git a/csharp_database_extension/CSharp Database Extension/Common/Attributes/Abstractions/Interfaces/IRelationAttribute.cs b/csharp_database_extension/CSharp Database Extension/Common/Attributes/Abstractions/Interfaces/IRelationAttribute.cs new file mode 100644 index 0000000..908926f --- /dev/null +++ b/csharp_database_extension/CSharp Database Extension/Common/Attributes/Abstractions/Interfaces/IRelationAttribute.cs @@ -0,0 +1,18 @@ +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; + +namespace CSharp_Database_Extension.Common.Attributes.Abstractions.Interfaces; + +/// +/// Represents an relation attribute. +/// +public interface IRelationAttribute { + /// + /// Relation name. + /// + string? Name { get; set; } + + /// + /// Wheter this relation references an entity on a different database. + /// + bool IsCrossDatabase { get; set; } +} diff --git a/CSM Database Core/Core/Attributes/EntityRelationAttribute.cs b/csharp_database_extension/CSharp Database Extension/Common/Attributes/EntityRelationAttribute.cs similarity index 50% rename from CSM Database Core/Core/Attributes/EntityRelationAttribute.cs rename to csharp_database_extension/CSharp Database Extension/Common/Attributes/EntityRelationAttribute.cs index 717bc23..b7db1de 100644 --- a/CSM Database Core/Core/Attributes/EntityRelationAttribute.cs +++ b/csharp_database_extension/CSharp Database Extension/Common/Attributes/EntityRelationAttribute.cs @@ -1,6 +1,6 @@ -using CSM_Database_Core.Core.Attributes.Abstractions.Bases; +using CSharp_Database_Extension.Common.Attributes.Abstractions.Bases; -namespace CSM_Database_Core.Core.Attributes; +namespace CSharp_Database_Extension.Common.Attributes; /// /// Attribute to mark a relation dependency. @@ -10,7 +10,7 @@ public class EntityRelationAttribute : RelationAttributeBase { /// - public EntityRelationAttribute(string? name = null) - : base(name) { + public EntityRelationAttribute(string? name = null, bool isCrossDatabase = false) + : base(name, isCrossDatabase) { } } diff --git a/csharp_database_extension/CSharp Database Extension/Common/Enums/DatabaseProviders.cs b/csharp_database_extension/CSharp Database Extension/Common/Enums/DatabaseProviders.cs new file mode 100644 index 0000000..d210023 --- /dev/null +++ b/csharp_database_extension/CSharp Database Extension/Common/Enums/DatabaseProviders.cs @@ -0,0 +1,17 @@ +namespace CSharp_Database_Extension.Common.Enums; + +/// +/// Represents the supported database providers. +/// +public enum DatabaseProviders { + + /// + /// Represents a Microsoft SQL Server database provider. + /// + SQLServer, + + /// + /// Represents a PostgreSQL database provider. + /// + PostgreSQL, +} diff --git a/CSM Database Core/Core/Errors/DatabaseError.cs b/csharp_database_extension/CSharp Database Extension/Common/Errors/DatabaseError.cs similarity index 91% rename from CSM Database Core/Core/Errors/DatabaseError.cs rename to csharp_database_extension/CSharp Database Extension/Common/Errors/DatabaseError.cs index 2399e6c..7b03260 100644 --- a/CSM Database Core/Core/Errors/DatabaseError.cs +++ b/csharp_database_extension/CSharp Database Extension/Common/Errors/DatabaseError.cs @@ -1,6 +1,6 @@ -using CSM_Foundation_Core.Errors.Abstractions.Bases; +using CSharp_Extension.Errors.Abstractions.Bases; -namespace CSM_Database_Core.Core.Errors; +namespace CSharp_Database_Extension.Common.Errors; /// /// Represents the exception events. diff --git a/CSM Database Core/Core/Errors/DepotError.cs b/csharp_database_extension/CSharp Database Extension/Common/Errors/DepotError.cs similarity index 89% rename from CSM Database Core/Core/Errors/DepotError.cs rename to csharp_database_extension/CSharp Database Extension/Common/Errors/DepotError.cs index 0bd48b7..95f3880 100644 --- a/CSM Database Core/Core/Errors/DepotError.cs +++ b/csharp_database_extension/CSharp Database Extension/Common/Errors/DepotError.cs @@ -1,12 +1,12 @@ -using CSM_Database_Core.Depots.Abstractions.Interfaces; -using CSM_Database_Core.Depots.Models; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Models; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -using CSM_Foundation_Core; -using CSM_Foundation_Core.Errors.Abstractions.Bases; -using CSM_Foundation_Core.Errors.Models; +using CSharp_Extension; +using CSharp_Extension.Errors.Abstractions.Bases; +using CSharp_Extension.Errors.Models; -namespace CSM_Database_Core.Core.Errors; +namespace CSharp_Database_Extension.Common.Errors; /// /// Represents the trigger events. diff --git a/CSM Database Core/Core/Errors/EntityError.cs b/csharp_database_extension/CSharp Database Extension/Common/Errors/EntityError.cs similarity index 92% rename from CSM Database Core/Core/Errors/EntityError.cs rename to csharp_database_extension/CSharp Database Extension/Common/Errors/EntityError.cs index d43eb62..1261b22 100644 --- a/CSM Database Core/Core/Errors/EntityError.cs +++ b/csharp_database_extension/CSharp Database Extension/Common/Errors/EntityError.cs @@ -1,8 +1,8 @@ -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -using CSM_Foundation_Core.Errors.Abstractions.Bases; +using CSharp_Extension.Errors.Abstractions.Bases; -namespace CSM_Database_Core.Core.Errors; +namespace CSharp_Database_Extension.Common.Errors; /// /// Represents exception events. diff --git a/CSM Database Core/Core/Errors/EntityValidationError.cs b/csharp_database_extension/CSharp Database Extension/Common/Errors/EntityValidationError.cs similarity index 90% rename from CSM Database Core/Core/Errors/EntityValidationError.cs rename to csharp_database_extension/CSharp Database Extension/Common/Errors/EntityValidationError.cs index f860103..1b9e37c 100644 --- a/CSM Database Core/Core/Errors/EntityValidationError.cs +++ b/csharp_database_extension/CSharp Database Extension/Common/Errors/EntityValidationError.cs @@ -1,8 +1,8 @@ -using CSM_Database_Core.Depots.Models; +using CSharp_Database_Extension.Depots.Models; -using CSM_Foundation_Core.Errors.Abstractions.Bases; +using CSharp_Extension.Errors.Abstractions.Bases; -namespace CSM_Database_Core.Core.Errors; +namespace CSharp_Database_Extension.Common.Errors; /// /// Represents events. diff --git a/CSM Database Core/Core/Errors/ValidatorError.cs b/csharp_database_extension/CSharp Database Extension/Common/Errors/ValidatorError.cs similarity index 87% rename from CSM Database Core/Core/Errors/ValidatorError.cs rename to csharp_database_extension/CSharp Database Extension/Common/Errors/ValidatorError.cs index 967e81c..2e69c07 100644 --- a/CSM Database Core/Core/Errors/ValidatorError.cs +++ b/csharp_database_extension/CSharp Database Extension/Common/Errors/ValidatorError.cs @@ -1,11 +1,11 @@ using System.Reflection; -using CSM_Database_Core.Entities.Abstractions.Interfaces; -using CSM_Database_Core.Validation.Abstractions.Bases; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Validation.Abstractions.Bases; -using CSM_Foundation_Core.Errors.Abstractions.Bases; +using CSharp_Extension.Errors.Abstractions.Bases; -namespace CSM_Database_Core.Core.Errors; +namespace CSharp_Database_Extension.Common.Errors; /// /// Represents events. diff --git a/CSM Database Core/Core/Extensions/EntityTypeBuilderExtension.cs b/csharp_database_extension/CSharp Database Extension/Common/Extensions/EntityTypeBuilderExtension.cs similarity index 98% rename from CSM Database Core/Core/Extensions/EntityTypeBuilderExtension.cs rename to csharp_database_extension/CSharp Database Extension/Common/Extensions/EntityTypeBuilderExtension.cs index c005dd5..5e0aeb5 100644 --- a/CSM Database Core/Core/Extensions/EntityTypeBuilderExtension.cs +++ b/csharp_database_extension/CSharp Database Extension/Common/Extensions/EntityTypeBuilderExtension.cs @@ -1,11 +1,11 @@ using System.Reflection; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace CSM_Database_Core.Core.Extensions; +namespace CSharp_Database_Extension.Common.Extensions; /// /// Provide extension methods for class type. diff --git a/CSM Database Core/Core/Extensions/IQueryableExtension.cs b/csharp_database_extension/CSharp Database Extension/Common/Extensions/IQueryableExtension.cs similarity index 96% rename from CSM Database Core/Core/Extensions/IQueryableExtension.cs rename to csharp_database_extension/CSharp Database Extension/Common/Extensions/IQueryableExtension.cs index e42c139..ee00551 100644 --- a/CSM Database Core/Core/Extensions/IQueryableExtension.cs +++ b/csharp_database_extension/CSharp Database Extension/Common/Extensions/IQueryableExtension.cs @@ -2,13 +2,13 @@ using System.Reflection; -using CSM_Database_Core.Depots.Abstractions.Interfaces; -using CSM_Database_Core.Depots.Models; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Models; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; using Microsoft.EntityFrameworkCore; -namespace CSM_Database_Core.Core.Extensions; +namespace CSharp_Database_Extension.Common.Extensions; /// /// Extension class for objects. diff --git a/CSM Database Core/Core/Extensions/TypeExtension.cs b/csharp_database_extension/CSharp Database Extension/Common/Extensions/TypeExtension.cs similarity index 97% rename from CSM Database Core/Core/Extensions/TypeExtension.cs rename to csharp_database_extension/CSharp Database Extension/Common/Extensions/TypeExtension.cs index 4f6c009..c7ae1e2 100644 --- a/CSM Database Core/Core/Extensions/TypeExtension.cs +++ b/csharp_database_extension/CSharp Database Extension/Common/Extensions/TypeExtension.cs @@ -1,7 +1,7 @@ using System.Collections; using System.Reflection; -namespace CSM_Database_Core.Core.Extensions; +namespace CSharp_Database_Extension.Common.Extensions; /// /// Provides extension methods for the class. diff --git a/CSM Database Core/Core/Models/ConnectionOptions.cs b/csharp_database_extension/CSharp Database Extension/Common/Models/ConnectionOptions.cs similarity index 96% rename from CSM Database Core/Core/Models/ConnectionOptions.cs rename to csharp_database_extension/CSharp Database Extension/Common/Models/ConnectionOptions.cs index 42f1bcb..3cd63fe 100644 --- a/CSM Database Core/Core/Models/ConnectionOptions.cs +++ b/csharp_database_extension/CSharp Database Extension/Common/Models/ConnectionOptions.cs @@ -1,4 +1,4 @@ -namespace CSM_Database_Core.Core.Models; +namespace CSharp_Database_Extension.Common.Models; /// /// Represents a database server connection options. diff --git a/CSM Database Core/Core/Models/DatabaseOptions.cs b/csharp_database_extension/CSharp Database Extension/Common/Models/DatabaseOptions.cs similarity index 62% rename from CSM Database Core/Core/Models/DatabaseOptions.cs rename to csharp_database_extension/CSharp Database Extension/Common/Models/DatabaseOptions.cs index 92f047b..a9b37c5 100644 --- a/CSM Database Core/Core/Models/DatabaseOptions.cs +++ b/csharp_database_extension/CSharp Database Extension/Common/Models/DatabaseOptions.cs @@ -1,6 +1,10 @@ -using Microsoft.EntityFrameworkCore; +using System.Reflection; -namespace CSM_Database_Core.Core.Models; +using CSharp_Database_Extension.Common.Enums; + +using Microsoft.EntityFrameworkCore; + +namespace CSharp_Database_Extension.Common.Models; /// /// Represents a building options. @@ -8,6 +12,21 @@ namespace CSM_Database_Core.Core.Models; public partial record DatabaseOptions where TDatabase : DbContext { + /// + /// Database signature. + /// + public string? Signature { get; set; } + + /// + /// Migrations assembly to use. + /// + public Assembly? Migrations { get; set; } + + /// + /// Database provider. + /// + public DatabaseProviders Provider { get; set; } = DatabaseProviders.PostgreSQL; + /// /// Whether the logging service is enabled. /// @@ -18,11 +37,6 @@ public partial record DatabaseOptions /// public bool ForTesting { get; init; } = false; - /// - /// Database context signature. - /// - public string? Sign { get; set; } - /// /// Database connection options. /// diff --git a/CSM Database Core/Core/Utils/DatabaseUtils.cs b/csharp_database_extension/CSharp Database Extension/Common/Utils/DatabaseUtils.cs similarity index 97% rename from CSM Database Core/Core/Utils/DatabaseUtils.cs rename to csharp_database_extension/CSharp Database Extension/Common/Utils/DatabaseUtils.cs index b2e3f9b..80e6187 100644 --- a/CSM Database Core/Core/Utils/DatabaseUtils.cs +++ b/csharp_database_extension/CSharp Database Extension/Common/Utils/DatabaseUtils.cs @@ -1,18 +1,18 @@ using System.Reflection; using System.Text.Json; -using CSM_Database_Core.Core.Attributes; -using CSM_Database_Core.Core.Models; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Common.Attributes; +using CSharp_Database_Extension.Common.Models; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -using CSM_Foundation_Core; -using CSM_Foundation_Core.Core.Errors; -using CSM_Foundation_Core.Core.Utils; +using CSharp_Extension; +using CSharp_Extension.Common.Utils; +using CSharp_Extension.Errors; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; -namespace CSM_Database_Core.Core.Utils; +namespace CSharp_Database_Extension.Common.Utils; /// /// Provide utilities methods for database purposes. @@ -114,7 +114,7 @@ public static ConnectionOptions GetConnectionOptions(string sign, bool forTestin string? appDirConnFile = appDirFiles .FirstOrDefault(file => file.Contains(fileName)); - if(appDirConnFile is null) { + if (appDirConnFile is null) { ConsoleUtils.Error( "Database connection options not found in app assemblies", details: new Dictionary { diff --git a/CSM Database Core/Core/Utils/EntityUtils.cs b/csharp_database_extension/CSharp Database Extension/Common/Utils/EntityUtils.cs similarity index 92% rename from CSM Database Core/Core/Utils/EntityUtils.cs rename to csharp_database_extension/CSharp Database Extension/Common/Utils/EntityUtils.cs index 96df204..4acd457 100644 --- a/CSM Database Core/Core/Utils/EntityUtils.cs +++ b/csharp_database_extension/CSharp Database Extension/Common/Utils/EntityUtils.cs @@ -1,10 +1,10 @@ using System.Collections; using System.Reflection; -using CSM_Database_Core.Core.Attributes.Abstractions.Interfaces; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Common.Attributes.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Core.Utils; +namespace CSharp_Database_Extension.Common.Utils; /// /// Provide utility methods for objects. diff --git a/CSM Database Core/Depots/Abstractions/Bases/DepotBase.cs b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Bases/DepotBase.cs similarity index 93% rename from CSM Database Core/Depots/Abstractions/Bases/DepotBase.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Bases/DepotBase.cs index 86f4f49..4424395 100644 --- a/CSM Database Core/Depots/Abstractions/Bases/DepotBase.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Bases/DepotBase.cs @@ -2,23 +2,23 @@ using System.Data; using System.Reflection; -using CSM_Database_Core.Core.Attributes.Abstractions.Interfaces; -using CSM_Database_Core.Core.Errors; -using CSM_Database_Core.Core.Extensions; -using CSM_Database_Core.Core.Utils; -using CSM_Database_Core.Depots.Abstractions.Interfaces; -using CSM_Database_Core.Depots.Models; -using CSM_Database_Core.Depots.Models.Structs; -using CSM_Database_Core.Entities.Abstractions.Interfaces; - -using CSM_Foundation_Core.Abstractions.Interfaces; -using CSM_Foundation_Core.Core.Errors; +using CSharp_Database_Extension.Common.Attributes.Abstractions.Interfaces; +using CSharp_Database_Extension.Common.Errors; +using CSharp_Database_Extension.Common.Extensions; +using CSharp_Database_Extension.Common.Utils; +using CSharp_Database_Extension.Depots.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Models; +using CSharp_Database_Extension.Depots.Models.Structs; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; + +using CSharp_Extension.Common.Abstractions.Interfaces; +using CSharp_Extension.Errors; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.IdentityModel.Tokens; -namespace CSM_Database_Core.Depots.Abstractions.Bases; +namespace CSharp_Database_Extension.Depots.Abstractions.Bases; /// /// @@ -124,7 +124,7 @@ public virtual async Task Create(TEntity entity) { TEntity instEntity = entity; instEntity.Timestamp = DateTime.UtcNow; - instEntity.EvaluateWrite(); + instEntity.EvaluateData(); instEntity = await DatabaseUtils.SanitizeEntity(_db, instEntity); await _dbSet.AddAsync(instEntity); @@ -171,7 +171,7 @@ public async Task Read(long id) { .FirstOrDefaultAsync() ?? throw new DepotError(DepotErrorEvents.UNFOUND, $"{nameof(IEntity.Id)} = {id}"); - entity.EvaluateRead(); + entity.EvaluateData(); return entity; } @@ -230,7 +230,7 @@ public async Task> Read(QueryInput> errors = []; foreach (TEntity item in resultItems) { try { - item.EvaluateRead(); + item.EvaluateData(); successes.Add(item); } catch (Exception exception) { EntityError error = new(EntityErrorEvents.READ_VALIDATION_FAILED, item, exception); @@ -319,12 +319,12 @@ public async Task> Update(QueryInput srcRelUpdates = relationUpdates.Value; PropertyInfo srcRelProp = trackedEntityBase.GetProperty(srcRelName); - + // Validating source entity relation property is a valid collection. - if(!srcRelProp.PropertyType.IsAssignableTo(typeof(IEnumerable))) + if (!srcRelProp.PropertyType.IsAssignableTo(typeof(IEnumerable))) throw new EntityError( - EntityErrorEvents.RELATION_NOT_COLLECTION, - updateEntity, + EntityErrorEvents.RELATION_NOT_COLLECTION, + updateEntity, new InvalidCastException($"Cannot cast relation ({srcRelName}) into [IEnumerable] object") ); @@ -348,7 +348,7 @@ public async Task> Update(QueryInput 1 && srcRelUpdates.Any( sourceRelUpdate => string.IsNullOrWhiteSpace(sourceRelUpdate.Key) @@ -364,15 +364,15 @@ public async Task> Update(QueryInput targetUpdate in srcRelUpdates) { string tarRelName = targetUpdate.Key; RelationUpdate[] tarRelUpdates = targetUpdate.Value; - + PropertyInfo? tarEntityRelRef; - if( + if ( string.IsNullOrWhiteSpace(tarRelName) ) { tarEntityRelRef = tarRelSrcProps[0]; - if(tarRelSrcProps.Length != 1) + if (tarRelSrcProps.Length != 1) throw new DepotError( - DepotErrorEvents.RELATIONS_UPDATE_MISMATCH_TARGET_REFS, + DepotErrorEvents.RELATIONS_UPDATE_MISMATCH_TARGET_REFS, exception: new InvalidOperationException($"Relations update were expecting 1 reference but got ({tarRelSrcProps}) at target entity type") ); } else { @@ -381,7 +381,7 @@ public async Task> Update(QueryInput( DepotErrorEvents.RELATIONS_UPDATE_MISMATCH_TARGET_REFS, exception: new InvalidOperationException($"Relations update were expecting a reference ({tarRelName}) but got ({tarRelSrcProps}) references at target entity type") @@ -397,29 +397,29 @@ public async Task> Update(QueryInput relationAddAction = (obj ) => { }; + Action relationAddAction = (obj) => { }; Action relationRemoveAction = (obj) => { }; - if(tarEntityRelRefType.IsAssignableTo(typeof(IEntity))) { + if (tarEntityRelRefType.IsAssignableTo(typeof(IEntity))) { relationAddAction = (obj) => { _db.Attach(obj); tarEntityRelRef.SetValue(obj, trackedEntity); }; relationRemoveAction = (obj) => { - object? currValue = tarEntityRelRef.GetValue(obj); - if(currValue is null) + object? currValue = tarEntityRelRef.GetValue(obj); + if (currValue is null) return; IEntity currValueEntity = (IEntity)currValue; - if(currValueEntity.Id != trackedEntity.Id) + if (currValueEntity.Id != trackedEntity.Id) return; tarEntityRelRef.SetValue(obj, null); }; - } - - if(tarEntityRelRefType.IsAssignableTo(typeof(IEnumerable))) { + } + + if (tarEntityRelRefType.IsAssignableTo(typeof(IEnumerable))) { relationAddAction = (obj) => { object? collectionItem = srcRelCastColl.FirstOrDefault( relationItem => relationItem.Id == obj.Id @@ -430,7 +430,7 @@ public async Task> Update(QueryInput> Update(QueryInput> Update(QueryInput /// [Delegate] declaration to expose an easier API to generate the accumulative instructions for the query after filtering. diff --git a/CSM Database Core/Depots/Abstractions/Interfaces/IDepotCreate.cs b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotCreate.cs similarity index 85% rename from CSM Database Core/Depots/Abstractions/Interfaces/IDepotCreate.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotCreate.cs index d13c624..95f754d 100644 --- a/CSM Database Core/Depots/Abstractions/Interfaces/IDepotCreate.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotCreate.cs @@ -1,7 +1,7 @@ -using CSM_Database_Core.Depots.Models; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Models; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Abstractions.Interfaces; +namespace CSharp_Database_Extension.Depots.Abstractions.Interfaces; /// /// Represents create logic for a . diff --git a/CSM Database Core/Depots/Abstractions/Interfaces/IDepotDelete.cs b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotDelete.cs similarity index 92% rename from CSM Database Core/Depots/Abstractions/Interfaces/IDepotDelete.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotDelete.cs index 2b3349b..127685f 100644 --- a/CSM Database Core/Depots/Abstractions/Interfaces/IDepotDelete.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotDelete.cs @@ -1,7 +1,7 @@ -using CSM_Database_Core.Depots.Models; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Models; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Abstractions.Interfaces; +namespace CSharp_Database_Extension.Depots.Abstractions.Interfaces; /// /// Represents deleting logic for a . diff --git a/CSM Database Core/Depots/Abstractions/Interfaces/IDepotRead.cs b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotRead.cs similarity index 88% rename from CSM Database Core/Depots/Abstractions/Interfaces/IDepotRead.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotRead.cs index 5c77158..11344e9 100644 --- a/CSM Database Core/Depots/Abstractions/Interfaces/IDepotRead.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotRead.cs @@ -1,7 +1,7 @@ -using CSM_Database_Core.Depots.Models; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Models; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Abstractions.Interfaces; +namespace CSharp_Database_Extension.Depots.Abstractions.Interfaces; /// /// Represents reading logic for a . diff --git a/CSM Database Core/Depots/Abstractions/Interfaces/IDepotUpdate.cs b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotUpdate.cs similarity index 77% rename from CSM Database Core/Depots/Abstractions/Interfaces/IDepotUpdate.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotUpdate.cs index 335af7f..a645702 100644 --- a/CSM Database Core/Depots/Abstractions/Interfaces/IDepotUpdate.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotUpdate.cs @@ -1,7 +1,7 @@ -using CSM_Database_Core.Depots.Models; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Models; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Abstractions.Interfaces; +namespace CSharp_Database_Extension.Depots.Abstractions.Interfaces; /// /// Represents updating logic for a . diff --git a/CSM Database Core/Depots/Abstractions/Interfaces/IDepotView.cs b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotView.cs similarity index 78% rename from CSM Database Core/Depots/Abstractions/Interfaces/IDepotView.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotView.cs index 2434b4c..558d616 100644 --- a/CSM Database Core/Depots/Abstractions/Interfaces/IDepotView.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IDepotView.cs @@ -1,7 +1,7 @@ -using CSM_Database_Core.Depots.Models; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Models; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Abstractions.Interfaces; +namespace CSharp_Database_Extension.Depots.Abstractions.Interfaces; /// /// Represents a [View] operations logic for a diff --git a/CSM Database Core/Depots/Abstractions/Interfaces/IUpdateEntityInput.cs b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IUpdateEntityInput.cs similarity index 85% rename from CSM Database Core/Depots/Abstractions/Interfaces/IUpdateEntityInput.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IUpdateEntityInput.cs index 56f16f1..5f71ff5 100644 --- a/CSM Database Core/Depots/Abstractions/Interfaces/IUpdateEntityInput.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IUpdateEntityInput.cs @@ -1,6 +1,6 @@ -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Abstractions.Interfaces; +namespace CSharp_Database_Extension.Depots.Abstractions.Interfaces; /// /// Represents an Entity shpaed update instructions input. diff --git a/CSM Database Core/Depots/Abstractions/Interfaces/IViewFilter.cs b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IViewFilter.cs similarity index 92% rename from CSM Database Core/Depots/Abstractions/Interfaces/IViewFilter.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IViewFilter.cs index 4db163e..12c87b4 100644 --- a/CSM Database Core/Depots/Abstractions/Interfaces/IViewFilter.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IViewFilter.cs @@ -1,11 +1,10 @@ -using CSM_Database_Core.Depots.ViewFilters; -using CSM_Database_Core.Entities.Abstractions.Bases; -using CSM_Database_Core.Entities.Abstractions.Interfaces; - -using System.Text.Json; +using System.Text.Json; using System.Text.Json.Serialization; -namespace CSM_Database_Core.Depots.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.ViewFilters; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; + +namespace CSharp_Database_Extension.Depots.Abstractions.Interfaces; /// /// for . @@ -79,7 +78,7 @@ public override bool CanConvert(Type typeToConvert) { /// /// /// -public class ISetViewFilterConverter +public class ISetViewFilterConverter : JsonConverter> where TSet : IEntity { /// diff --git a/CSM Database Core/Depots/Abstractions/Interfaces/IViewFilterNode.cs b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IViewFilterNode.cs similarity index 89% rename from CSM Database Core/Depots/Abstractions/Interfaces/IViewFilterNode.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IViewFilterNode.cs index 3ff8876..3de8be5 100644 --- a/CSM Database Core/Depots/Abstractions/Interfaces/IViewFilterNode.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Abstractions/Interfaces/IViewFilterNode.cs @@ -2,13 +2,13 @@ using System.Text.Json; using System.Text.Json.Serialization; -using CSM_Database_Core.Depots.ViewFilters; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.ViewFilters; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -using CSM_Foundation_Core.Convertion.Abstractions.Bases; -using CSM_Foundation_Core.Convertion.Abstractions.Interfaces; +using CSharp_Extension.Convertion.Abstractions.Bases; +using CSharp_Extension.Convertion.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Abstractions.Interfaces; +namespace CSharp_Database_Extension.Depots.Abstractions.Interfaces; /// /// Represents a View system filter node, building and evaluating by itself (implementations) the way the View operation will be filtered. diff --git a/CSM Database Core/Depots/Models/BatchOperationOutput.cs b/csharp_database_extension/CSharp Database Extension/Depots/Models/BatchOperationOutput.cs similarity index 92% rename from CSM Database Core/Depots/Models/BatchOperationOutput.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Models/BatchOperationOutput.cs index db05ad5..1f6505a 100644 --- a/CSM Database Core/Depots/Models/BatchOperationOutput.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Models/BatchOperationOutput.cs @@ -1,7 +1,7 @@ -using CSM_Database_Core.Core.Errors; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Common.Errors; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Models; +namespace CSharp_Database_Extension.Depots.Models; /// /// [Record] that stores the information about a batch operation output result. diff --git a/CSM Database Core/Depots/Models/FilterQueryInput.cs b/csharp_database_extension/CSharp Database Extension/Depots/Models/FilterQueryInput.cs similarity index 89% rename from CSM Database Core/Depots/Models/FilterQueryInput.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Models/FilterQueryInput.cs index db62110..5cbc3ba 100644 --- a/CSM Database Core/Depots/Models/FilterQueryInput.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Models/FilterQueryInput.cs @@ -1,8 +1,8 @@ using System.Linq.Expressions; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Models; +namespace CSharp_Database_Extension.Depots.Models; /// diff --git a/CSM Database Core/Depots/Models/PaginationOutput.cs b/csharp_database_extension/CSharp Database Extension/Depots/Models/PaginationOutput.cs similarity index 89% rename from CSM Database Core/Depots/Models/PaginationOutput.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Models/PaginationOutput.cs index 4dbb348..abb7f73 100644 --- a/CSM Database Core/Depots/Models/PaginationOutput.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Models/PaginationOutput.cs @@ -1,6 +1,6 @@ -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Models; +namespace CSharp_Database_Extension.Depots.Models; /// /// [Output] object for a pagination proccess result information. diff --git a/CSM Database Core/Depots/Models/PropertyValidationResult.cs b/csharp_database_extension/CSharp Database Extension/Depots/Models/PropertyValidationResult.cs similarity index 80% rename from CSM Database Core/Depots/Models/PropertyValidationResult.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Models/PropertyValidationResult.cs index 24c7e99..2fff84d 100644 --- a/CSM Database Core/Depots/Models/PropertyValidationResult.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Models/PropertyValidationResult.cs @@ -1,8 +1,8 @@ using System.Reflection; -using CSM_Database_Core.Core.Errors; +using CSharp_Database_Extension.Common.Errors; -namespace CSM_Database_Core.Depots.Models; +namespace CSharp_Database_Extension.Depots.Models; /// /// Represents an Entity property validation result. diff --git a/CSM Database Core/Depots/Models/QueryInput.cs b/csharp_database_extension/CSharp Database Extension/Depots/Models/QueryInput.cs similarity index 80% rename from CSM Database Core/Depots/Models/QueryInput.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Models/QueryInput.cs index bb88eef..417dc29 100644 --- a/CSM Database Core/Depots/Models/QueryInput.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Models/QueryInput.cs @@ -1,7 +1,7 @@ -using CSM_Database_Core.Depots.Abstractions.Interfaces; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Models; +namespace CSharp_Database_Extension.Depots.Models; /// /// [Record] for specific operations, diff --git a/CSM Database Core/Depots/Models/Structs/RelationUpdate.cs b/csharp_database_extension/CSharp Database Extension/Depots/Models/Structs/RelationUpdate.cs similarity index 85% rename from CSM Database Core/Depots/Models/Structs/RelationUpdate.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Models/Structs/RelationUpdate.cs index 2b769b4..4883f66 100644 --- a/CSM Database Core/Depots/Models/Structs/RelationUpdate.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Models/Structs/RelationUpdate.cs @@ -1,6 +1,6 @@ -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Models.Structs; +namespace CSharp_Database_Extension.Depots.Models.Structs; /// /// Represents available actions to perform for a . diff --git a/CSM Database Core/Depots/Models/UpdateInput.cs b/csharp_database_extension/CSharp Database Extension/Depots/Models/UpdateInput.cs similarity index 89% rename from CSM Database Core/Depots/Models/UpdateInput.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Models/UpdateInput.cs index e5966f4..ca09762 100644 --- a/CSM Database Core/Depots/Models/UpdateInput.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Models/UpdateInput.cs @@ -1,7 +1,7 @@ -using CSM_Database_Core.Depots.Models.Structs; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Models.Structs; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Models; +namespace CSharp_Database_Extension.Depots.Models; /// /// [Record] for single update operation. diff --git a/CSM Database Core/Depots/Models/UpdateOutput.cs b/csharp_database_extension/CSharp Database Extension/Depots/Models/UpdateOutput.cs similarity index 80% rename from CSM Database Core/Depots/Models/UpdateOutput.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Models/UpdateOutput.cs index b1b8b35..56d018c 100644 --- a/CSM Database Core/Depots/Models/UpdateOutput.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Models/UpdateOutput.cs @@ -1,7 +1,6 @@ -using CSM_Database_Core.Entities.Abstractions.Bases; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Models; +namespace CSharp_Database_Extension.Depots.Models; /// /// [Record] for the output of an entity [Update] operation. diff --git a/CSM Database Core/Depots/Models/ViewInput.cs b/csharp_database_extension/CSharp Database Extension/Depots/Models/ViewInput.cs similarity index 88% rename from CSM Database Core/Depots/Models/ViewInput.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Models/ViewInput.cs index 221b03a..45cc1ca 100644 --- a/CSM Database Core/Depots/Models/ViewInput.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Models/ViewInput.cs @@ -1,8 +1,7 @@ -using CSM_Database_Core.Depots.Abstractions.Interfaces; -using CSM_Database_Core.Entities.Abstractions.Bases; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Models; +namespace CSharp_Database_Extension.Depots.Models; /// /// Defines options to build a [View] diff --git a/CSM Database Core/Depots/Models/ViewOrdering.cs b/csharp_database_extension/CSharp Database Extension/Depots/Models/ViewOrdering.cs similarity index 93% rename from CSM Database Core/Depots/Models/ViewOrdering.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Models/ViewOrdering.cs index 256dfb1..0c4a5ed 100644 --- a/CSM Database Core/Depots/Models/ViewOrdering.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Models/ViewOrdering.cs @@ -1,4 +1,4 @@ -namespace CSM_Database_Core.Depots.Models; +namespace CSharp_Database_Extension.Depots.Models; /// /// Stores a ordering step options for the /// builder, indicating how the current ordering step should behave. diff --git a/CSM Database Core/Depots/Models/ViewOutput.cs b/csharp_database_extension/CSharp Database Extension/Depots/Models/ViewOutput.cs similarity index 83% rename from CSM Database Core/Depots/Models/ViewOutput.cs rename to csharp_database_extension/CSharp Database Extension/Depots/Models/ViewOutput.cs index f721f26..8c6a93d 100644 --- a/CSM Database Core/Depots/Models/ViewOutput.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/Models/ViewOutput.cs @@ -1,8 +1,7 @@ -using CSM_Database_Core.Depots.Abstractions.Interfaces; -using CSM_Database_Core.Entities.Abstractions.Bases; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.Models; +namespace CSharp_Database_Extension.Depots.Models; /// /// {model} class for . @@ -17,18 +16,17 @@ namespace CSM_Database_Core.Depots.Models; /// public class ViewOutput where TEntity : IEntity { - - TEntity[] _Records = []; /// /// The collection of items gathered. /// public required TEntity[] Entities { - get => _Records; + get; init { - _Records = value; + field = value; Length = value.Length; } - } + } = []; + /// /// The available pages. /// diff --git a/CSM Database Core/Depots/ViewFilters/ViewFilterDate.cs b/csharp_database_extension/CSharp Database Extension/Depots/ViewFilters/ViewFilterDate.cs similarity index 91% rename from CSM Database Core/Depots/ViewFilters/ViewFilterDate.cs rename to csharp_database_extension/CSharp Database Extension/Depots/ViewFilters/ViewFilterDate.cs index f922ed2..20ece75 100644 --- a/CSM Database Core/Depots/ViewFilters/ViewFilterDate.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/ViewFilters/ViewFilterDate.cs @@ -1,9 +1,9 @@ using System.Linq.Expressions; -using CSM_Database_Core.Depots.Abstractions.Interfaces; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.ViewFilters; +namespace CSharp_Database_Extension.Depots.ViewFilters; /// /// {implementation} for . diff --git a/CSM Database Core/Depots/ViewFilters/ViewFilterLogical.cs b/csharp_database_extension/CSharp Database Extension/Depots/ViewFilters/ViewFilterLogical.cs similarity index 93% rename from CSM Database Core/Depots/ViewFilters/ViewFilterLogical.cs rename to csharp_database_extension/CSharp Database Extension/Depots/ViewFilters/ViewFilterLogical.cs index 848a2c8..5fe5787 100644 --- a/CSM Database Core/Depots/ViewFilters/ViewFilterLogical.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/ViewFilters/ViewFilterLogical.cs @@ -1,9 +1,9 @@ using System.Linq.Expressions; -using CSM_Database_Core.Depots.Abstractions.Interfaces; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.ViewFilters; +namespace CSharp_Database_Extension.Depots.ViewFilters; /// /// {implementation} for . diff --git a/CSM Database Core/Depots/ViewFilters/ViewFilterProperty.cs b/csharp_database_extension/CSharp Database Extension/Depots/ViewFilters/ViewFilterProperty.cs similarity index 95% rename from CSM Database Core/Depots/ViewFilters/ViewFilterProperty.cs rename to csharp_database_extension/CSharp Database Extension/Depots/ViewFilters/ViewFilterProperty.cs index 6f6b87f..ea35b74 100644 --- a/CSM Database Core/Depots/ViewFilters/ViewFilterProperty.cs +++ b/csharp_database_extension/CSharp Database Extension/Depots/ViewFilters/ViewFilterProperty.cs @@ -2,10 +2,10 @@ using System.Reflection; using System.Text.Json; -using CSM_Database_Core.Depots.Abstractions.Interfaces; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Depots.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; -namespace CSM_Database_Core.Depots.ViewFilters; +namespace CSharp_Database_Extension.Depots.ViewFilters; /// /// Stores the available options for [View] [Filter] behavior. diff --git a/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Bases/EntityBase.cs b/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Bases/EntityBase.cs new file mode 100644 index 0000000..d8b217c --- /dev/null +++ b/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Bases/EntityBase.cs @@ -0,0 +1,102 @@ +using System.ComponentModel.DataAnnotations.Schema; +using System.Reflection; +using System.Text.Json.Serialization; + +using CSharp_Database_Extension.Entities.Validation.Abstractions.Bases; +using CSharp_Database_Extension.Entities.Validation.Models; + +using CSharp_Extension.Common.Abstractions.Bases; + +namespace CSharp_Database_Extension; + +/// +public abstract partial class EntityBase + : EntityBase, IEntity + where TStatus : class, IEntity + where TUser : class, IEntity { + + /// + public TStatus SystemStatus { get; set; } = default!; + + /// + public TUser EntityOwner { get; set; } = default!; +} + +/// +public abstract partial class EntityBase + : ObjectBase, IEntity { + + #region Server Side Properties + + /// + [NotMapped, JsonPropertyOrder(0)] + public string Discriminator { get; init; } + + /// + [NotMapped, JsonIgnore] + public abstract Type Database { get; init; } + + #endregion + + /// + public long Id { get; set; } + + /// + public string Name { get; set; } = string.Empty; + + /// + public string? Description { get; set; } + + /// + public DateTime Timestamp { get; set; } = DateTime.UtcNow; + + /// + /// Creates a new instance. + /// + public EntityBase() { + Discriminator = $"{GetType().GUID}"; + } + + /// + public void EvaluateData() { + foreach (PropertyInfo property in GetType().GetProperties()) { + + IEnumerable attributes = property.GetCustomAttributes(); + if (!attributes.Any()) + return; + + foreach (ValidatorBase validator in attributes) { + validator.Validate(this); + } + } + } + + /// + public EntityEvaluationFailure[] EvaluateModel() { + + Type modelType = GetType(); + PropertyInfo[] modelProps = modelType.GetProperties(); + + List failures = []; + foreach (PropertyInfo property in modelProps) { + + IEnumerable attributes = property.GetCustomAttributes(); + if (!attributes.Any()) + continue; + + foreach (ValidatorBase validator in attributes) { + if (!validator.ValidateType(modelType)) { + failures.Add( + new EntityEvaluationFailure { + Property = property, + Validator = validator, + Type = EntityEvaluationFailures.WRONG_VALIDATOR_TYPE + } + ); + } + } + } + + return [.. failures]; + } +} \ No newline at end of file diff --git a/CSM Database Core/Entities/Abstractions/Bases/PartnerBridgeEntityBase.cs b/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Bases/PartnerBridgeEntityBase.cs similarity index 93% rename from CSM Database Core/Entities/Abstractions/Bases/PartnerBridgeEntityBase.cs rename to csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Bases/PartnerBridgeEntityBase.cs index 1a817c6..70fd383 100644 --- a/CSM Database Core/Entities/Abstractions/Bases/PartnerBridgeEntityBase.cs +++ b/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Bases/PartnerBridgeEntityBase.cs @@ -1,8 +1,8 @@ -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace CSM_Database_Core.Entities.Abstractions.Bases; +namespace CSharp_Database_Extension.Entities.Abstractions.Bases; /// /// Represents an that holds a scope between internal ( tenant business entities data ) and external ( tenant partners entities data ). diff --git a/CSM Database Core/Entities/Abstractions/Bases/PartnerScopeEntityBase.cs b/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Bases/PartnerScopeEntityBase.cs similarity index 89% rename from CSM Database Core/Entities/Abstractions/Bases/PartnerScopeEntityBase.cs rename to csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Bases/PartnerScopeEntityBase.cs index 7c5b593..b315b7a 100644 --- a/CSM Database Core/Entities/Abstractions/Bases/PartnerScopeEntityBase.cs +++ b/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Bases/PartnerScopeEntityBase.cs @@ -1,11 +1,11 @@ using System.Reflection; -using CSM_Database_Core.Core.Extensions; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension.Common.Extensions; +using CSharp_Database_Extension.Entities.Abstractions.Interfaces; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace CSM_Database_Core.Entities.Abstractions.Bases; +namespace CSharp_Database_Extension.Entities.Abstractions.Bases; /// /// Represents an scope for a . diff --git a/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Interfaces/IEntity.cs b/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Interfaces/IEntity.cs new file mode 100644 index 0000000..9c3fe7f --- /dev/null +++ b/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Interfaces/IEntity.cs @@ -0,0 +1,91 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text.Json.Serialization; + +using CSharp_Database_Extension.Common.Attributes; +using CSharp_Database_Extension.Entities.Validation.Models; + +using CSharp_Extension.Convertion.Abstractions.Interfaces; + +#pragma warning disable IDE0130 // Namespace does not match folder structure +namespace CSharp_Database_Extension; +#pragma warning restore IDE0130 // Namespace does not match folder structure + + +/// +/// Represents a business entity model with status relation. +/// +/// +/// Type of the status entity model. +/// +/// +/// Type of the user entity model. +/// +public partial interface IEntity + : IEntity + where TStatus : class, IEntity + where TUser : class, IEntity { + + /// + /// System level entity status. + /// + [NotMapped, EntityRelation(IsCrossDatabase = true)] + TStatus SystemStatus { get; set; } + + /// + /// Last user that owned this entity. + /// + [NotMapped, EntityRelation(IsCrossDatabase = true)] + TUser EntityOwner { get; set; } +} + +/// +/// Represents a business entity model. +/// +public partial interface IEntity + : IConverterVariant { + + /// + /// Database that owns this entity model. + /// + [JsonIgnore, NotMapped] + Type Database { get; init; } + + /// + /// Database identifier. + /// + long Id { get; set; } + + /// + /// Entity name. + /// + /// + /// Length min 1, max 200. + /// + [StringLength(200, MinimumLength = 1)] + string Name { get; set; } + + /// + /// Entity description. + /// + string? Description { get; set; } + + /// + /// Last entity change timestamp. + /// + DateTime Timestamp { get; set; } + + /// + /// Evaluates current entity data integrity at Read or Write operations in database. This prevents possible user level direct databases + /// modifications. + /// + void EvaluateData(); + + /// + /// Evaluate that entity model is correctly configured. + /// + /// + /// Evaluation failures. + /// + EntityEvaluationFailure[] EvaluateModel(); +} \ No newline at end of file diff --git a/CSM Database Core/Entities/Abstractions/Interfaces/IPartnerBridgeEntity.cs b/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Interfaces/IPartnerBridgeEntity.cs similarity index 94% rename from CSM Database Core/Entities/Abstractions/Interfaces/IPartnerBridgeEntity.cs rename to csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Interfaces/IPartnerBridgeEntity.cs index 67765ef..c152df2 100644 --- a/CSM Database Core/Entities/Abstractions/Interfaces/IPartnerBridgeEntity.cs +++ b/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Interfaces/IPartnerBridgeEntity.cs @@ -1,4 +1,4 @@ -namespace CSM_Database_Core.Entities.Abstractions.Interfaces; +namespace CSharp_Database_Extension.Entities.Abstractions.Interfaces; /// /// Represents an as a bridge between a possible internal business entity or a partner provided entity data. diff --git a/CSM Database Core/Entities/Abstractions/Interfaces/IPartnerScopeEntity.cs b/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Interfaces/IPartnerScopeEntity.cs similarity index 90% rename from CSM Database Core/Entities/Abstractions/Interfaces/IPartnerScopeEntity.cs rename to csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Interfaces/IPartnerScopeEntity.cs index d4fb1f5..9075739 100644 --- a/CSM Database Core/Entities/Abstractions/Interfaces/IPartnerScopeEntity.cs +++ b/csharp_database_extension/CSharp Database Extension/Entities/Abstractions/Interfaces/IPartnerScopeEntity.cs @@ -1,4 +1,4 @@ -namespace CSM_Database_Core.Entities.Abstractions.Interfaces; +namespace CSharp_Database_Extension.Entities.Abstractions.Interfaces; /// /// Represents an scope for a . /// diff --git a/CSM Database Core/Validation/Abstractions/Bases/ValidatorBase.cs b/csharp_database_extension/CSharp Database Extension/Entities/Validation/Abstractions/Bases/ValidatorBase.cs similarity index 65% rename from CSM Database Core/Validation/Abstractions/Bases/ValidatorBase.cs rename to csharp_database_extension/CSharp Database Extension/Entities/Validation/Abstractions/Bases/ValidatorBase.cs index 074152e..a56cc02 100644 --- a/CSM Database Core/Validation/Abstractions/Bases/ValidatorBase.cs +++ b/csharp_database_extension/CSharp Database Extension/Entities/Validation/Abstractions/Bases/ValidatorBase.cs @@ -1,6 +1,6 @@ -using CSM_Database_Core.Validation.Abstractions.Interfaces; +using CSharp_Database_Extension.Entities.Validation.Abstractions.Interfaces; -namespace CSM_Database_Core.Validation.Abstractions.Bases; +namespace CSharp_Database_Extension.Entities.Validation.Abstractions.Bases; /// [AttributeUsage(AttributeTargets.Property)] diff --git a/CSM Database Core/Validation/Abstractions/Interfaces/IValidator.cs b/csharp_database_extension/CSharp Database Extension/Entities/Validation/Abstractions/Interfaces/IValidator.cs similarity index 90% rename from CSM Database Core/Validation/Abstractions/Interfaces/IValidator.cs rename to csharp_database_extension/CSharp Database Extension/Entities/Validation/Abstractions/Interfaces/IValidator.cs index 5c9ee89..d3d3326 100644 --- a/CSM Database Core/Validation/Abstractions/Interfaces/IValidator.cs +++ b/csharp_database_extension/CSharp Database Extension/Entities/Validation/Abstractions/Interfaces/IValidator.cs @@ -1,4 +1,4 @@ -namespace CSM_Database_Core.Validation.Abstractions.Interfaces; +namespace CSharp_Database_Extension.Entities.Validation.Abstractions.Interfaces; /// /// Represents a property validator instruction. diff --git a/CSM Database Core/Validation/ExclusiveValidator.cs b/csharp_database_extension/CSharp Database Extension/Entities/Validation/ExclusiveValidator.cs similarity index 92% rename from CSM Database Core/Validation/ExclusiveValidator.cs rename to csharp_database_extension/CSharp Database Extension/Entities/Validation/ExclusiveValidator.cs index 16f8c6c..92aef81 100644 --- a/CSM Database Core/Validation/ExclusiveValidator.cs +++ b/csharp_database_extension/CSharp Database Extension/Entities/Validation/ExclusiveValidator.cs @@ -1,11 +1,11 @@ using System.Reflection; -using CSM_Database_Core.Validation.Abstractions.Bases; +using CSharp_Database_Extension.Entities.Validation.Abstractions.Bases; -namespace CSM_Database_Core.Validation; +namespace CSharp_Database_Extension.Entities.Validation; /// -/// +/// Repreents an Entity Model property groups strict assigantion validator. /// [AttributeUsage(AttributeTargets.Property)] public class ExclusiveValidator diff --git a/csharp_database_extension/CSharp Database Extension/Entities/Validation/Models/EntityEvaluationFailure.cs b/csharp_database_extension/CSharp Database Extension/Entities/Validation/Models/EntityEvaluationFailure.cs new file mode 100644 index 0000000..68396f6 --- /dev/null +++ b/csharp_database_extension/CSharp Database Extension/Entities/Validation/Models/EntityEvaluationFailure.cs @@ -0,0 +1,37 @@ +using System.Reflection; + +using CSharp_Database_Extension.Entities.Validation.Abstractions.Bases; + +namespace CSharp_Database_Extension.Entities.Validation.Models; + +/// +/// Represents types of . +/// +public enum EntityEvaluationFailures { + /// + /// When a property validator has unsupported type for that property. + /// + WRONG_VALIDATOR_TYPE, +} + +/// +/// Represents an entity validation result data. +/// +public record EntityEvaluationFailure { + + /// + /// Property caught in validation process. + /// + public PropertyInfo Property { get; init; } = default!; + + /// + /// Validator that was used to validate the property. + /// + public ValidatorBase Validator { get; init; } = default!; + + /// + /// Type of validation result. + /// + public EntityEvaluationFailures Type { get; init; } = default!; + +} diff --git a/csharp_database_extension/CSharp Database Extension/release-notes/v0.0.1-beta.md b/csharp_database_extension/CSharp Database Extension/release-notes/v0.0.1-beta.md new file mode 100644 index 0000000..c3e9259 --- /dev/null +++ b/csharp_database_extension/CSharp Database Extension/release-notes/v0.0.1-beta.md @@ -0,0 +1,64 @@ +## Release 0.0.1-beta + +### Commits included + +- Merge branch 'vbump_0.0.1-beta' of https://github.com/Cosmos-CSM/fe_csharp_database into vbump_0.0.1-beta (Juan Renato Urrea Ortiz) +- preventing looping (Juan Renato Urrea Ortiz) +- Generated vdocs. (github-actions) +- Generated vdocs. (github-actions) +- Generated vdocs. (github-actions) +- fixing version check (Juan Renato Urrea Ortiz) +- fixing error (Juan Renato Urrea Ortiz) +- Merge branch 'vbump_0.0.1-beta' of https://github.com/Cosmos-CSM/fe_csharp_database into vbump_0.0.1-beta (Juan Renato Urrea Ortiz) +- adding a branch check (Juan Renato Urrea Ortiz) +- Generated vdocs. (github-actions) +- Generated vdocs. (github-actions) +- Generated vdocs. (github-actions) +- fixed ident (Juan Renato Urrea Ortiz) +- added message (Juan Renato Urrea Ortiz) +- fixed all syntax (Juan Renato Urrea Ortiz) +- fixing arguments (Juan Renato Urrea Ortiz) +- fixed syntax (Juan Renato Urrea Ortiz) +- fixed syntax error (Juan Renato Urrea Ortiz) +- testing new version (Juan Renato Urrea Ortiz) +- trying another apporach (Juan Renato Urrea Ortiz) +- trying single line approach (Juan Renato Urrea Ortiz) +- corrected a workflow var (Juan Renato Urrea Ortiz) +- testing workflow to auto-generate release docs (Juan Renato Urrea Ortiz) +- Merge branch 'main' into dev (Renato Urrea) +- Merge branch 'dev' of https://github.com/Cosmos-CSM/fe_csharp_database into dev (Juan Renato Urrea Ortiz) +- adding package metadata and bump checker (Juan Renato Urrea Ortiz) +- Merge branch 'main' into dev (Renato Urrea) +- removing cd workflows (Juan Renato Urrea Ortiz) +- Merge pull request #47 from Cosmos-CSM/46-standarize-repository (Renato Urrea) +- adding nuget source (Juan Renato Urrea Ortiz) +- last try (Juan Renato Urrea Ortiz) +- another try (Juan Renato Urrea Ortiz) +- aother update (Juan Renato Urrea Ortiz) +- updating workflow (Juan Renato Urrea Ortiz) +- trying again (Juan Renato Urrea Ortiz) +- applying checks (Juan Renato Urrea Ortiz) +- changing approach (Juan Renato Urrea Ortiz) +- checking now (Juan Renato Urrea Ortiz) +- adding git attributes (Juan Renato Urrea Ortiz) +- trying something else (Juan Renato Urrea Ortiz) +- pusing eol validation (Juan Renato Urrea Ortiz) +- updating cd workflows (Juan Renato Urrea Ortiz) +- fixing CI (Juan Renato Urrea Ortiz) +- updating CI workflow (Juan Renato Urrea Ortiz) +- added unit tests project, correected ci workflow (Juan Renato Urrea Ortiz) +- finishing standarization and ready to go first version (Juan Renato Urrea Ortiz) +- structuring multi providers (Juan Renato Urrea Ortiz) +- integration tests added pending to check (Renato Urrea) +- testing and main project building (Renato Urrea) +- Checking project adjustments and content (Renato Urrea) +- organizing solution (Juan Renato Urrea Ortiz) +- file structuring (Juan Renato Urrea Ortiz) +- Merge pull request #45 from Cosmos-CSM/dev@issue_41_43 (Renato Urrea) +- Summary definitions changes (jr110) +- testing methods optimizations (jr110) +- pull dev changes (jr110) +- removing unnecesary sync methods in csm database testing (jr110) +- Issue #44 - Adding get method in [TestingStoreManager] (jr110) +- Issue #41 - Adding async support for testing methods (jr110) +- forgot include (Juan Renato Urrea Ortiz) \ No newline at end of file diff --git a/DatabaseProxy/DatabaseProxy.cs b/csharp_database_extension/DatabaseProxy/DatabaseProxy.cs similarity index 86% rename from DatabaseProxy/DatabaseProxy.cs rename to csharp_database_extension/DatabaseProxy/DatabaseProxy.cs index 0350bf6..5cec6a7 100644 --- a/DatabaseProxy/DatabaseProxy.cs +++ b/csharp_database_extension/DatabaseProxy/DatabaseProxy.cs @@ -1,5 +1,5 @@ -using CSM_Database_Core; -using CSM_Database_Core.Core.Models; +using CSharp_Database_Extension; +using CSharp_Database_Extension.Common.Models; using DatabaseProxy.Entities; @@ -14,7 +14,7 @@ public class DatabaseProxy : DatabaseBase { /// - public override string Sign { get; protected set; } = "CSMDQ"; + public override string Signature { get; protected set; } = "CSMDQ"; /// public DatabaseProxy() diff --git a/DatabaseProxy/DatabaseProxy.csproj b/csharp_database_extension/DatabaseProxy/DatabaseProxy.csproj similarity index 68% rename from DatabaseProxy/DatabaseProxy.csproj rename to csharp_database_extension/DatabaseProxy/DatabaseProxy.csproj index 10d670e..b36e7a3 100644 --- a/DatabaseProxy/DatabaseProxy.csproj +++ b/csharp_database_extension/DatabaseProxy/DatabaseProxy.csproj @@ -14,13 +14,7 @@ - - - - - - PreserveNewest - + diff --git a/DatabaseProxy/DatabaseProxyDesignFactory.cs b/csharp_database_extension/DatabaseProxy/DatabaseProxyDesignFactory.cs similarity index 55% rename from DatabaseProxy/DatabaseProxyDesignFactory.cs rename to csharp_database_extension/DatabaseProxy/DatabaseProxyDesignFactory.cs index df30d77..4630595 100644 --- a/DatabaseProxy/DatabaseProxyDesignFactory.cs +++ b/csharp_database_extension/DatabaseProxy/DatabaseProxyDesignFactory.cs @@ -1,25 +1,25 @@ -using CSM_Foundation_Core.Core.Utils; +using CSharp_Extension.Common.Utils; using Microsoft.EntityFrameworkCore.Design; -namespace CSM_Security_Database_Core; +namespace DatabaseProxy; /// /// EF Design time factory for /// internal class DatabaseProxyDesignFactory - : IDesignTimeDbContextFactory { + : IDesignTimeDbContextFactory { - public DatabaseProxy.DatabaseProxy CreateDbContext(string[] args) { + public DatabaseProxy CreateDbContext(string[] args) { ConsoleUtils.Warning( "Designing database using a design factory", new Dictionary { { "DesignFactory", GetType().FullName }, - { "Database", typeof(DatabaseProxy.DatabaseProxy).FullName }, + { "Database", typeof(DatabaseProxy).FullName }, } ); - return new DatabaseProxy.DatabaseProxy(); + return new DatabaseProxy(); } } diff --git a/DatabaseProxy/DepotProxy.cs b/csharp_database_extension/DatabaseProxy/DepotProxy.cs similarity index 59% rename from DatabaseProxy/DepotProxy.cs rename to csharp_database_extension/DatabaseProxy/DepotProxy.cs index be208e7..b549561 100644 --- a/DatabaseProxy/DepotProxy.cs +++ b/csharp_database_extension/DatabaseProxy/DepotProxy.cs @@ -1,7 +1,7 @@ -using CSM_Database_Core.Depots.Abstractions.Bases; -using CSM_Database_Core.Entities.Abstractions.Interfaces; +using CSharp_Database_Extension; +using CSharp_Database_Extension.Depots.Abstractions.Bases; -using CSM_Foundation_Core.Abstractions.Interfaces; +using CSharp_Extension.Common.Abstractions.Interfaces; using DatabaseProxy.Entities; diff --git a/DatabaseProxy/Entities/EntityDependantProxy.cs b/csharp_database_extension/DatabaseProxy/Entities/EntityDependantProxy.cs similarity index 83% rename from DatabaseProxy/Entities/EntityDependantProxy.cs rename to csharp_database_extension/DatabaseProxy/Entities/EntityDependantProxy.cs index 82aaa8b..2c8cea4 100644 --- a/DatabaseProxy/Entities/EntityDependantProxy.cs +++ b/csharp_database_extension/DatabaseProxy/Entities/EntityDependantProxy.cs @@ -1,6 +1,6 @@ -using CSM_Database_Core; -using CSM_Database_Core.Core.Attributes; -using CSM_Database_Core.Core.Extensions; +using CSharp_Database_Extension; +using CSharp_Database_Extension.Common.Attributes; +using CSharp_Database_Extension.Common.Extensions; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/DatabaseProxy/Entities/EntityDependencyProxy.cs b/csharp_database_extension/DatabaseProxy/Entities/EntityDependencyProxy.cs similarity index 79% rename from DatabaseProxy/Entities/EntityDependencyProxy.cs rename to csharp_database_extension/DatabaseProxy/Entities/EntityDependencyProxy.cs index a5ee98c..fcaffa5 100644 --- a/DatabaseProxy/Entities/EntityDependencyProxy.cs +++ b/csharp_database_extension/DatabaseProxy/Entities/EntityDependencyProxy.cs @@ -1,5 +1,5 @@ -using CSM_Database_Core; -using CSM_Database_Core.Core.Attributes; +using CSharp_Database_Extension; +using CSharp_Database_Extension.Common.Attributes; namespace DatabaseProxy.Entities; diff --git a/DatabaseProxy/Entities/EntityProxy.cs b/csharp_database_extension/DatabaseProxy/Entities/EntityProxy.cs similarity index 86% rename from DatabaseProxy/Entities/EntityProxy.cs rename to csharp_database_extension/DatabaseProxy/Entities/EntityProxy.cs index af1d99c..5c37921 100644 --- a/DatabaseProxy/Entities/EntityProxy.cs +++ b/csharp_database_extension/DatabaseProxy/Entities/EntityProxy.cs @@ -1,6 +1,6 @@ -using CSM_Database_Core; -using CSM_Database_Core.Core.Attributes; -using CSM_Database_Core.Core.Extensions; +using CSharp_Database_Extension; +using CSharp_Database_Extension.Common.Attributes; +using CSharp_Database_Extension.Common.Extensions; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/DatabaseProxy/csmdq.dev.connection.json b/csharp_database_extension/DatabaseProxy/csmdq.dev.connection.json similarity index 100% rename from DatabaseProxy/csmdq.dev.connection.json rename to csharp_database_extension/DatabaseProxy/csmdq.dev.connection.json diff --git a/Integration Tests/Integration Tests.csproj b/csharp_database_extension/Integration Tests/Integration Tests.csproj similarity index 83% rename from Integration Tests/Integration Tests.csproj rename to csharp_database_extension/Integration Tests/Integration Tests.csproj index c28a224..e9bde07 100644 --- a/Integration Tests/Integration Tests.csproj +++ b/csharp_database_extension/Integration Tests/Integration Tests.csproj @@ -21,8 +21,8 @@ - - + + diff --git a/csharp_database_extension/Integration Tests/Tests/DatabaseBaseTests.cs b/csharp_database_extension/Integration Tests/Tests/DatabaseBaseTests.cs new file mode 100644 index 0000000..f87d60b --- /dev/null +++ b/csharp_database_extension/Integration Tests/Tests/DatabaseBaseTests.cs @@ -0,0 +1,6 @@ +using CSharp_Database_Extension_Testing.Abstractions.Bases; + +namespace Integration_Tests.Tests; + +public class DatabaseBaseTests : DatabaseIntegrationTestsBase { +} diff --git a/Integration Tests/Tests/DepotBaseTests.cs b/csharp_database_extension/Integration Tests/Tests/DepotBaseTests.cs similarity index 89% rename from Integration Tests/Tests/DepotBaseTests.cs rename to csharp_database_extension/Integration Tests/Tests/DepotBaseTests.cs index a48bffb..3453d3a 100644 --- a/Integration Tests/Tests/DepotBaseTests.cs +++ b/csharp_database_extension/Integration Tests/Tests/DepotBaseTests.cs @@ -1,8 +1,7 @@ -using CSM_Database_Core.Depots.Abstractions.Bases; -using CSM_Database_Core.Depots.Models; -using CSM_Database_Core.Depots.Models.Structs; +using CSharp_Database_Extension.Depots.Models; +using CSharp_Database_Extension.Depots.Models.Structs; -using CSM_Database_Testing.Abstractions.Bases; +using CSharp_Database_Extension_Testing.Abstractions.Bases; using DatabaseProxy; using DatabaseProxy.Entities; @@ -17,8 +16,11 @@ namespace Integration_Tests.Tests; public class DepotBaseTests : DepotIntegrationTestsBase { - protected override EntityProxy EntityFactory(string Entropy) { + protected override async Task EntityFactory(string Entropy) { return new EntityProxy { + EntityDependencyProxy = await _storeManager.Store( + new EntityDependencyProxy() + ) }; } @@ -96,4 +98,5 @@ await Store( updatedEntity.EntityDependencyProxy.Id ); } + } diff --git a/Unit Tests/Tests/UtilsTests/DatabaseUtilsTests.cs b/csharp_database_extension/Unit Tests/Tests/UtilsTests/DatabaseUtilsTests.cs similarity index 94% rename from Unit Tests/Tests/UtilsTests/DatabaseUtilsTests.cs rename to csharp_database_extension/Unit Tests/Tests/UtilsTests/DatabaseUtilsTests.cs index 53be18c..b2151a1 100644 --- a/Unit Tests/Tests/UtilsTests/DatabaseUtilsTests.cs +++ b/csharp_database_extension/Unit Tests/Tests/UtilsTests/DatabaseUtilsTests.cs @@ -1,4 +1,4 @@ -using CSM_Database_Core.Core.Utils; +using CSharp_Database_Extension.Common.Utils; using DatabaseProxy.Entities; diff --git a/Unit Tests/Unit Tests.csproj b/csharp_database_extension/Unit Tests/Unit Tests.csproj similarity index 92% rename from Unit Tests/Unit Tests.csproj rename to csharp_database_extension/Unit Tests/Unit Tests.csproj index f10ade8..d894d38 100644 --- a/Unit Tests/Unit Tests.csproj +++ b/csharp_database_extension/Unit Tests/Unit Tests.csproj @@ -25,7 +25,7 @@ - + diff --git a/local.integration_tests.runsettings b/csharp_database_extension/local.integration_tests.runsettings similarity index 65% rename from local.integration_tests.runsettings rename to csharp_database_extension/local.integration_tests.runsettings index ad856dc..5d37eac 100644 --- a/local.integration_tests.runsettings +++ b/csharp_database_extension/local.integration_tests.runsettings @@ -4,7 +4,7 @@ net10.0 TestResults - C:\Users\Usuar\Desktop\workspaces\Cosmos (CSM)\csm_database\DatabaseProxy\csmdq.dev.connection.json + C:\Users\Usuar\Desktop\db-extension.itests.json \ No newline at end of file diff --git a/csmpackage.json b/csmpackage.json index 3d42074..86e74e5 100644 --- a/csmpackage.json +++ b/csmpackage.json @@ -1,5 +1,5 @@ { - "version": "0.0.0", + "version": "0.0.1-beta", "packages": [ "csharp_database_extension/CSharp Database Extension", "csharp_database_extension/CSharp Database Extension Testing" diff --git a/pr_summary.md b/pr_summary.md new file mode 100644 index 0000000..8c0eee3 --- /dev/null +++ b/pr_summary.md @@ -0,0 +1,83 @@ +### PR Summary + +**Title:** vbump: 0.0.1 beta + +**Author:** @RMotive + +**Description:** + +No description provided. + +**Labels:** None + +### Changes + +**Files modified:** +- .gitattributes +- .github/workflows/cd-1.yml +- .github/workflows/ci.yaml +- CSM Database Core/Abstractions/Interfaces/IDatabase.cs +- CSM Database Core/CHANGELOG.md +- CSM Database Core/Core/Attributes/Abstractions/Bases/RelationAttributeBase.cs +- CSM Database Core/Core/Attributes/Abstractions/Interfaces/IRelationAttribute.cs +- CSM Database Core/Entities/Abstractions/Bases/ActivableEntityBase.cs +- CSM Database Core/Entities/Abstractions/Bases/EntityBase.cs +- CSM Database Core/Entities/Abstractions/Bases/NamedEntityBase.cs +- CSM Database Core/Entities/Abstractions/Interfaces/IActivableEntity.cs +- CSM Database Core/Entities/Abstractions/Interfaces/IEntity.cs +- CSM Database Core/Entities/Abstractions/Interfaces/INamedEntity.cs +- CSM Database Testing/CHANGELOG.md +- CSM Database Testing/Disposing/Abstractions/Interfaces/ITestingDisposer.cs +- DatabaseProxy/Migrations/20260401220538_Init Db.Designer.cs +- DatabaseProxy/Migrations/20260401220538_Init Db.cs +- DatabaseProxy/Migrations/20260401221950_Init_Db_2.Designer.cs +- DatabaseProxy/Migrations/20260401221950_Init_Db_2.cs +- DatabaseProxy/Migrations/20260506231958_added_autoloading.Designer.cs +- DatabaseProxy/Migrations/20260506231958_added_autoloading.cs +- DatabaseProxy/Migrations/20260506232702_added_renamings.Designer.cs +- DatabaseProxy/Migrations/20260506232702_added_renamings.cs +- DatabaseProxy/Migrations/20260506232938_added_attributes.Designer.cs +- DatabaseProxy/Migrations/20260506232938_added_attributes.cs +- DatabaseProxy/Migrations/20260506233726_added_attributes_2.Designer.cs +- DatabaseProxy/Migrations/20260506233726_added_attributes_2.cs +- DatabaseProxy/Migrations/20260507000230_standarized db for proxies.Designer.cs +- DatabaseProxy/Migrations/20260507000230_standarized db for proxies.cs +- DatabaseProxy/Migrations/20260507000851_standarized db for proxies 2.Designer.cs + +**Commits:** +- forgot include +- Issue #41 - Adding async support for testing methods +- Issue #44 - Adding get method in [TestingStoreManager] +- removing unnecesary sync methods in csm database testing +- pull dev changes +- testing methods optimizations +- Summary definitions changes +- Merge pull request #45 from Cosmos-CSM/dev@issue_41_43 +- +- Dev@issue_41_43_44 --> Dev +- file structuring +- organizing solution +- Checking project adjustments and content +- testing and main project building +- integration tests added pending to check +- structuring multi providers +- finishing standarization and ready to go first version +- added unit tests project, correected ci workflow +- updating CI workflow +- fixing CI +- updating cd workflows +- pusing eol validation +- trying something else +- adding git attributes +- checking now +- changing approach +- applying checks +- trying again +- updating workflow +- aother update +- another try +- last try + +### Notes + +- Generated from PR metadata: title, body, labels, files, commits.