diff --git a/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj b/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj
index 679b491..33b7efa 100644
--- a/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj
@@ -5,7 +5,7 @@
AnyCPU;x64;x86
EasyMicroservices
true
- 0.0.0.46
+ 0.0.0.47
asp core servces.
EasyMicroservices@gmail.com
core,cores,base,database,services,asp,aspnet
diff --git a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj
index c26d2ac..22a99cf 100644
--- a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj
@@ -5,7 +5,7 @@
AnyCPU;x64;x86
EasyMicroservices
true
- 0.0.0.46
+ 0.0.0.47
asp core servces.
EasyMicroservices@gmail.com
core,cores,base,database,services,asp,aspnet,aspcore,efcore
diff --git a/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj b/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj
index 46c10e0..be30312 100644
--- a/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj
@@ -5,7 +5,7 @@
AnyCPU;x64;x86
EasyMicroservices
true
- 0.0.0.46
+ 0.0.0.47
core contracts.
EasyMicroservices@gmail.com
core,cores,base,contract,contracts,dto,dtos
diff --git a/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs b/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs
index 87a3bd5..abf4b69 100644
--- a/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs
+++ b/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs
@@ -215,8 +215,7 @@ public async Task> GetBy(IEasyRea
var entityResult = await GetBy(easyReadableQueryable, predicate, query, true, cancellationToken);
if (!entityResult)
return entityResult.ToContract();
- var result = await _mapperProvider.MapAsync(entityResult.Result);
- ValidateMappedResult(ref result);
+ var result = await MapAsync(entityResult.Result);
return result;
}
@@ -238,8 +237,7 @@ protected async Task> GetById();
- var result = await _mapperProvider.MapAsync(entityResult.Result);
- ValidateMappedResult(ref result);
+ var result = await MapAsync(entityResult.Result);
return result;
}
@@ -263,8 +261,7 @@ public async Task> GetByUniqueIdentity();
- var result = await _mapperProvider.MapAsync(entityResult.Result);
- ValidateMappedResult(ref result);
+ var result = await MapAsync(entityResult.Result);
return result;
}
@@ -335,8 +332,7 @@ protected async Task> Filter(
var entityResult = await Filter(filterRequest, easyReadableQueryable, query, cancellationToken);
if (!entityResult)
return entityResult.ToAnotherListContract();
- var result = await _mapperProvider.MapToListAsync(entityResult.Result);
- ValidateMappedResult(ref result);
+ var result = await MapToListAsync(entityResult.Result);
return result;
}
@@ -377,8 +373,7 @@ protected async Task> GetAll(
var entityResult = await GetAll(easyReadableQueryable, query, cancellationToken);
if (!entityResult)
return entityResult.ToAnotherListContract();
- var result = await _mapperProvider.MapToListAsync(entityResult.Result);
- ValidateMappedResult(ref result);
+ var result = await MapToListAsync(entityResult.Result);
return result;
}
@@ -402,8 +397,7 @@ public async Task> GetAllByUniqueIdentity();
- var result = await _mapperProvider.MapToListAsync(entityResult.Result);
- ValidateMappedResult(ref result);
+ var result = await MapToListAsync(entityResult.Result);
return result;
}
@@ -474,13 +468,11 @@ private async Task> InternalUpdateBulk(IEa
public async Task> Update(IEasyWritableQueryableAsync easyWritableQueryable, TUpdateContract contract, CancellationToken cancellationToken = default)
where TEntity : class
{
- var entity = await _mapperProvider.MapAsync(contract);
- ValidateMappedResult(ref entity);
+ var entity = await MapAsync(contract);
var result = await Update(easyWritableQueryable, entity, cancellationToken);
if (!result)
return result.ToContract();
- var mappedResult = await _mapperProvider.MapAsync(result.Result);
- ValidateMappedResult(ref mappedResult);
+ var mappedResult = await MapAsync(result.Result);
return mappedResult;
}
@@ -496,8 +488,7 @@ public async Task> Update UpdateBulk(IEasyWritableQueryableAsync easyWritableQueryable, UpdateBulkRequestContract request, CancellationToken cancellationToken = default)
where TEntity : class
{
- var entities = await _mapperProvider.MapToListAsync(request.Items);
- ValidateMappedResult(ref entities);
+ var entities = await MapToListAsync(request.Items);
var result = await InternalUpdateBulk(easyWritableQueryable, entities, cancellationToken, false, true);
return result;
}
@@ -740,8 +731,7 @@ public async Task AddBulk(IEasyWritableQueryableAsync<
public async Task> Add(IEasyWritableQueryableAsync easyWritableQueryable, TContract contract, CancellationToken cancellationToken = default)
where TEntity : class
{
- var entity = await _mapperProvider.MapAsync(contract);
- ValidateMappedResult(ref entity);
+ var entity = await MapAsync(contract);
var result = await Add(easyWritableQueryable, entity, cancellationToken);
return result;
}
@@ -758,9 +748,44 @@ public async Task> Add(IEasyWritabl
public async Task AddBulk(IEasyWritableQueryableAsync easyWritableQueryable, CreateBulkRequestContract request, CancellationToken cancellationToken = default)
where TEntity : class
{
- var entities = await _mapperProvider.MapToListAsync(request.Items);
- ValidateMappedResult(ref entities);
- var result = await AddBulk(easyWritableQueryable, entities, cancellationToken);
+ var entities = await MapToListAsync(request.Items);
+ var result = await AddBulk(easyWritableQueryable, entities, cancellationToken);
+ return result;
+ }
+
+ #endregion
+
+ #region Map
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected async Task> MapToListAsync(IEnumerable items)
+ {
+ if (typeof(TFrom) == typeof(TTo))
+ return items.Cast().ToList();
+ var result = await _mapperProvider.MapToListAsync(items);
+ ValidateMappedResult(ref result);
+ return result;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected async Task MapAsync(TFrom item)
+ {
+ if (typeof(TFrom) == typeof(TTo))
+ return (TTo)(object)item;
+ var result = await _mapperProvider.MapAsync(item);
+ ValidateMappedResult(ref result);
return result;
}
diff --git a/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseMappedLogicBase.cs b/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseMappedLogicBase.cs
index aa2328b..a40539e 100644
--- a/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseMappedLogicBase.cs
+++ b/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseMappedLogicBase.cs
@@ -6,7 +6,6 @@
using EasyMicroservices.Mapper.Interfaces;
using EasyMicroservices.ServiceContracts;
using System;
-using System.Diagnostics.Contracts;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
@@ -112,7 +111,7 @@ public async Task> Add(TCreateRequestContract
var result = await Add(_easyWriteableQueryable, contract, cancellationToken);
if (!result)
return result.ToContract();
- var mapped = await _mapperProvider.MapAsync(result.Result);
+ var mapped = await MapAsync(result.Result);
ValidateMappedResult(ref mapped);
return mapped;
}
diff --git a/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj b/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj
index 582ed7d..4b3176e 100644
--- a/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj
@@ -5,7 +5,7 @@
AnyCPU;x64;x86
EasyMicroservices
true
- 0.0.0.46
+ 0.0.0.47
core of database.
EasyMicroservices@gmail.com
core,cores,base,database
diff --git a/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj b/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj
index ee052cf..c096adc 100644
--- a/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj
@@ -5,7 +5,7 @@
AnyCPU;x64;x86
EasyMicroservices
true
- 0.0.0.46
+ 0.0.0.47
ef core of database.
EasyMicroservices@gmail.com
core,cores,base,database,ef,efcore
diff --git a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj
index c5e7edf..b8f1205 100644
--- a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj
@@ -5,7 +5,7 @@
AnyCPU;x64;x86
EasyMicroservices
true
- 0.0.0.46
+ 0.0.0.47
ef core of Relational database.
EasyMicroservices@gmail.com
core,cores,base,database,ef,efcore,Relational