From 948d07054f721b7f28b2c2edbc76ae17fe7756c3 Mon Sep 17 00:00:00 2001 From: Kevin J Lambert Date: Thu, 27 Jun 2024 14:29:05 -0400 Subject: [PATCH] get rid of functional extensions --- .../Handlers/CreationHandler.cs | 7 +++---- .../YuckQi.Data.DocumentDb.DynamoDb.csproj | 2 +- .../Handlers/CreationHandler.cs | 7 +++---- .../YuckQi.Data.DocumentDb.MongoDb.csproj | 2 +- src/YuckQi.Data.MemDb/Handlers/CreationHandler.cs | 7 +++---- src/YuckQi.Data.MemDb/YuckQi.Data.MemDb.csproj | 2 +- .../YuckQi.Data.Sql.Dapper.MySql.csproj | 2 +- .../YuckQi.Data.Sql.Dapper.Oracle.csproj | 2 +- .../YuckQi.Data.Sql.Dapper.SqlServer.csproj | 2 +- .../Handlers/CreationHandler.cs | 9 ++++----- .../YuckQi.Data.Sql.Dapper.csproj | 2 +- .../YuckQi.Data.Sql.EntityFramework.csproj | 2 +- .../Handlers/Abstract/CreationHandlerBase.cs | 15 +++++++-------- src/YuckQi.Data/YuckQi.Data.csproj | 3 +-- 14 files changed, 29 insertions(+), 35 deletions(-) diff --git a/src/YuckQi.Data.DocumentDb.DynamoDb/Handlers/CreationHandler.cs b/src/YuckQi.Data.DocumentDb.DynamoDb/Handlers/CreationHandler.cs index d1d6fd1..3898cbc 100644 --- a/src/YuckQi.Data.DocumentDb.DynamoDb/Handlers/CreationHandler.cs +++ b/src/YuckQi.Data.DocumentDb.DynamoDb/Handlers/CreationHandler.cs @@ -1,5 +1,4 @@ using Amazon.DynamoDBv2.DataModel; -using CSharpFunctionalExtensions; using YuckQi.Data.Handlers.Abstract; using YuckQi.Data.Handlers.Options; using YuckQi.Domain.Aspects.Abstract; @@ -57,7 +56,7 @@ public override async Task> Create(IEnumerable ent return list; } - protected override Maybe DoCreate(TEntity entity, TScope? scope) + protected override TIdentifier? DoCreate(TEntity entity, TScope? scope) { if (scope == null) throw new ArgumentNullException(nameof(scope)); @@ -68,7 +67,7 @@ public override async Task> Create(IEnumerable ent return result; } - protected override async Task> DoCreate(TEntity entity, TScope? scope, CancellationToken cancellationToken) + protected override async Task DoCreate(TEntity entity, TScope? scope, CancellationToken cancellationToken) { if (scope == null) throw new ArgumentNullException(nameof(scope)); @@ -78,6 +77,6 @@ public override async Task> Create(IEnumerable ent await table.PutItemAsync(scope.ToDocument(document), cancellationToken); - return Maybe.From(entity.Identifier); + return entity.Identifier; } } diff --git a/src/YuckQi.Data.DocumentDb.DynamoDb/YuckQi.Data.DocumentDb.DynamoDb.csproj b/src/YuckQi.Data.DocumentDb.DynamoDb/YuckQi.Data.DocumentDb.DynamoDb.csproj index 49a3027..3d1a85c 100644 --- a/src/YuckQi.Data.DocumentDb.DynamoDb/YuckQi.Data.DocumentDb.DynamoDb.csproj +++ b/src/YuckQi.Data.DocumentDb.DynamoDb/YuckQi.Data.DocumentDb.DynamoDb.csproj @@ -5,7 +5,7 @@ enable true Kevin J Lambert - 6.5.0 + 6.5.1 An implementation of YuckQi.Data for Amazon DynamoDB databases. YuckQi.Data https://github.com/Yuck/YuckQi.Data.git diff --git a/src/YuckQi.Data.DocumentDb.MongoDb/Handlers/CreationHandler.cs b/src/YuckQi.Data.DocumentDb.MongoDb/Handlers/CreationHandler.cs index 8ac9097..73bd304 100644 --- a/src/YuckQi.Data.DocumentDb.MongoDb/Handlers/CreationHandler.cs +++ b/src/YuckQi.Data.DocumentDb.MongoDb/Handlers/CreationHandler.cs @@ -1,5 +1,4 @@ -using CSharpFunctionalExtensions; -using MongoDB.Driver; +using MongoDB.Driver; using YuckQi.Data.DocumentDb.MongoDb.Extensions; using YuckQi.Data.Handlers.Abstract; using YuckQi.Data.Handlers.Options; @@ -54,7 +53,7 @@ public override async Task> Create(IEnumerable ent return list; } - protected override Maybe DoCreate(TEntity entity, TScope? scope) + protected override TIdentifier? DoCreate(TEntity entity, TScope? scope) { if (scope == null) throw new ArgumentNullException(nameof(scope)); @@ -68,7 +67,7 @@ public override async Task> Create(IEnumerable ent return document.GetIdentifier(); } - protected override async Task> DoCreate(TEntity entity, TScope? scope, CancellationToken cancellationToken) + protected override async Task DoCreate(TEntity entity, TScope? scope, CancellationToken cancellationToken) { if (scope == null) throw new ArgumentNullException(nameof(scope)); diff --git a/src/YuckQi.Data.DocumentDb.MongoDb/YuckQi.Data.DocumentDb.MongoDb.csproj b/src/YuckQi.Data.DocumentDb.MongoDb/YuckQi.Data.DocumentDb.MongoDb.csproj index e8f7282..2d7a391 100644 --- a/src/YuckQi.Data.DocumentDb.MongoDb/YuckQi.Data.DocumentDb.MongoDb.csproj +++ b/src/YuckQi.Data.DocumentDb.MongoDb/YuckQi.Data.DocumentDb.MongoDb.csproj @@ -5,7 +5,7 @@ enable true Kevin J Lambert - 6.5.0 + 6.5.1 An implementation of YuckQi.Data for MongoDB databases. YuckQi.Data https://github.com/Yuck/YuckQi.Data.git diff --git a/src/YuckQi.Data.MemDb/Handlers/CreationHandler.cs b/src/YuckQi.Data.MemDb/Handlers/CreationHandler.cs index 1688ed1..ab50cdb 100644 --- a/src/YuckQi.Data.MemDb/Handlers/CreationHandler.cs +++ b/src/YuckQi.Data.MemDb/Handlers/CreationHandler.cs @@ -1,5 +1,4 @@ using System.Collections.Concurrent; -using CSharpFunctionalExtensions; using YuckQi.Data.Handlers.Abstract; using YuckQi.Data.Handlers.Options; using YuckQi.Domain.Aspects.Abstract; @@ -16,13 +15,13 @@ public CreationHandler(ConcurrentDictionary entities, Crea _entities = entities ?? throw new ArgumentNullException(nameof(entities)); } - protected override Maybe DoCreate(TEntity entity, TScope? scope) + protected override TIdentifier? DoCreate(TEntity entity, TScope? scope) { if (entity.Identifier == null) throw new InvalidOperationException(); - return _entities.TryAdd(entity.Identifier, entity) ? entity.Identifier : Maybe.None; + return _entities.TryAdd(entity.Identifier, entity) ? entity.Identifier : default; } - protected override Task> DoCreate(TEntity entity, TScope? scope, CancellationToken cancellationToken) => Task.FromResult(DoCreate(entity, scope)); + protected override Task DoCreate(TEntity entity, TScope? scope, CancellationToken cancellationToken) => Task.FromResult(DoCreate(entity, scope)); } diff --git a/src/YuckQi.Data.MemDb/YuckQi.Data.MemDb.csproj b/src/YuckQi.Data.MemDb/YuckQi.Data.MemDb.csproj index 46e031c..a27275d 100644 --- a/src/YuckQi.Data.MemDb/YuckQi.Data.MemDb.csproj +++ b/src/YuckQi.Data.MemDb/YuckQi.Data.MemDb.csproj @@ -5,7 +5,7 @@ enable true Kevin J Lambert - 6.5.0 + 6.5.1 An implementation of YuckQi.Data for a in-memory "database" (ConcurrentDictionary), ideal for rapid development without external dependencies. YuckQi.Data https://github.com/Yuck/YuckQi.Data.git diff --git a/src/YuckQi.Data.Sql.Dapper.MySql/YuckQi.Data.Sql.Dapper.MySql.csproj b/src/YuckQi.Data.Sql.Dapper.MySql/YuckQi.Data.Sql.Dapper.MySql.csproj index 72fd5b1..434e182 100644 --- a/src/YuckQi.Data.Sql.Dapper.MySql/YuckQi.Data.Sql.Dapper.MySql.csproj +++ b/src/YuckQi.Data.Sql.Dapper.MySql/YuckQi.Data.Sql.Dapper.MySql.csproj @@ -5,7 +5,7 @@ enable true Kevin J Lambert - 6.5.0 + 6.5.1 An implementation of YuckQi.Data for MySQL databases using Dapper and SimpleCRUD. YuckQi.Data https://github.com/Yuck/YuckQi.Data.git diff --git a/src/YuckQi.Data.Sql.Dapper.Oracle/YuckQi.Data.Sql.Dapper.Oracle.csproj b/src/YuckQi.Data.Sql.Dapper.Oracle/YuckQi.Data.Sql.Dapper.Oracle.csproj index 88de840..72c28b6 100644 --- a/src/YuckQi.Data.Sql.Dapper.Oracle/YuckQi.Data.Sql.Dapper.Oracle.csproj +++ b/src/YuckQi.Data.Sql.Dapper.Oracle/YuckQi.Data.Sql.Dapper.Oracle.csproj @@ -5,7 +5,7 @@ enable true Kevin J Lambert - 6.5.0 + 6.5.1 An implementation of YuckQi.Data for Oracle databases using Dapper and SimpleCRUD. YuckQi.Data https://github.com/Yuck/YuckQi.Data.git diff --git a/src/YuckQi.Data.Sql.Dapper.SqlServer/YuckQi.Data.Sql.Dapper.SqlServer.csproj b/src/YuckQi.Data.Sql.Dapper.SqlServer/YuckQi.Data.Sql.Dapper.SqlServer.csproj index df4a417..8ac7b9b 100644 --- a/src/YuckQi.Data.Sql.Dapper.SqlServer/YuckQi.Data.Sql.Dapper.SqlServer.csproj +++ b/src/YuckQi.Data.Sql.Dapper.SqlServer/YuckQi.Data.Sql.Dapper.SqlServer.csproj @@ -5,7 +5,7 @@ enable true Kevin J Lambert - 6.5.0 + 6.5.1 An implementation of YuckQi.Data for MSSQL databases using Dapper and SimpleCRUD. YuckQi.Data https://github.com/Yuck/YuckQi.Data.git diff --git a/src/YuckQi.Data.Sql.Dapper/Handlers/CreationHandler.cs b/src/YuckQi.Data.Sql.Dapper/Handlers/CreationHandler.cs index 339755f..edd159d 100644 --- a/src/YuckQi.Data.Sql.Dapper/Handlers/CreationHandler.cs +++ b/src/YuckQi.Data.Sql.Dapper/Handlers/CreationHandler.cs @@ -1,5 +1,4 @@ using System.Data; -using CSharpFunctionalExtensions; using Dapper; using YuckQi.Data.Handlers.Abstract; using YuckQi.Data.Handlers.Options; @@ -22,23 +21,23 @@ public CreationHandler(IMapper? mapper) : base(mapper) { } public CreationHandler(CreationOptions? options, IMapper? mapper) : base(options, mapper) { } - protected override Maybe DoCreate(TEntity entity, TScope? scope) + protected override TIdentifier? DoCreate(TEntity entity, TScope? scope) { if (scope == null) throw new ArgumentNullException(nameof(scope)); var record = MapToData(entity) ?? throw new InvalidOperationException(); - return Maybe.From(scope.Connection.Insert(record, scope)); + return scope.Connection.Insert(record, scope); } - protected override async Task> DoCreate(TEntity entity, TScope? scope, CancellationToken cancellationToken) + protected override Task DoCreate(TEntity entity, TScope? scope, CancellationToken cancellationToken) { if (scope == null) throw new ArgumentNullException(nameof(scope)); var record = MapToData(entity) ?? throw new InvalidOperationException(); - return Maybe.From(await scope.Connection.InsertAsync(record, scope)); + return scope.Connection.InsertAsync(record, scope); } } diff --git a/src/YuckQi.Data.Sql.Dapper/YuckQi.Data.Sql.Dapper.csproj b/src/YuckQi.Data.Sql.Dapper/YuckQi.Data.Sql.Dapper.csproj index 21f10ca..cc0efb0 100644 --- a/src/YuckQi.Data.Sql.Dapper/YuckQi.Data.Sql.Dapper.csproj +++ b/src/YuckQi.Data.Sql.Dapper/YuckQi.Data.Sql.Dapper.csproj @@ -5,7 +5,7 @@ enable true Kevin J Lambert - 6.5.0 + 6.5.1 An implementation of YuckQi.Data for SQL databases using Dapper and SimpleCRUD. YuckQi.Data https://github.com/Yuck/YuckQi.Data.git diff --git a/src/YuckQi.Data.Sql.EntityFramework/YuckQi.Data.Sql.EntityFramework.csproj b/src/YuckQi.Data.Sql.EntityFramework/YuckQi.Data.Sql.EntityFramework.csproj index 2b95696..695caa9 100644 --- a/src/YuckQi.Data.Sql.EntityFramework/YuckQi.Data.Sql.EntityFramework.csproj +++ b/src/YuckQi.Data.Sql.EntityFramework/YuckQi.Data.Sql.EntityFramework.csproj @@ -5,7 +5,7 @@ enable true Kevin J Lambert - 6.5.0 + 6.5.1 An implementation of YuckQi.Data for SQL databases using Entity Framework. YuckQi.Data https://github.com/Yuck/YuckQi.Data.git diff --git a/src/YuckQi.Data/Handlers/Abstract/CreationHandlerBase.cs b/src/YuckQi.Data/Handlers/Abstract/CreationHandlerBase.cs index bbe330e..2f83cc3 100644 --- a/src/YuckQi.Data/Handlers/Abstract/CreationHandlerBase.cs +++ b/src/YuckQi.Data/Handlers/Abstract/CreationHandlerBase.cs @@ -1,5 +1,4 @@ -using CSharpFunctionalExtensions; -using YuckQi.Data.Exceptions; +using YuckQi.Data.Exceptions; using YuckQi.Data.Handlers.Options; using YuckQi.Domain.Aspects.Abstract; using YuckQi.Domain.Entities.Abstract; @@ -37,10 +36,10 @@ public TEntity Create(TEntity entity, TScope? scope) revised.RevisionMomentUtc = entity.CreationMomentUtc; var identifier = DoCreate(entity, scope); - if (identifier.HasNoValue) + if (identifier == null) throw new CreationException(); - entity.Identifier = identifier.Value; + entity.Identifier = identifier; return entity; } @@ -65,10 +64,10 @@ public async Task Create(TEntity entity, TScope? scope, CancellationTok revised.RevisionMomentUtc = entity.CreationMomentUtc; var identifier = await DoCreate(entity, scope, cancellationToken); - if (identifier.HasNoValue) + if (identifier == null) throw new CreationException(); - entity.Identifier = identifier.Value; + entity.Identifier = identifier; return entity; } @@ -81,7 +80,7 @@ public virtual async Task> Create(IEnumerable enti return results; } - protected abstract Maybe DoCreate(TEntity entity, TScope? scope); + protected abstract TIdentifier? DoCreate(TEntity entity, TScope? scope); - protected abstract Task> DoCreate(TEntity entity, TScope? scope, CancellationToken cancellationToken); + protected abstract Task DoCreate(TEntity entity, TScope? scope, CancellationToken cancellationToken); } diff --git a/src/YuckQi.Data/YuckQi.Data.csproj b/src/YuckQi.Data/YuckQi.Data.csproj index f254870..d0ccb06 100644 --- a/src/YuckQi.Data/YuckQi.Data.csproj +++ b/src/YuckQi.Data/YuckQi.Data.csproj @@ -5,7 +5,7 @@ enable true Kevin J Lambert - 6.5.0 + 6.5.1 A .NET library of lightweight data access handlers which can be used to compose repositories and domain services. https://github.com/Yuck/YuckQi.Data.git git @@ -20,7 +20,6 @@ -