diff --git a/src/Core/Grand.Data/Grand.Data.csproj b/src/Core/Grand.Data/Grand.Data.csproj
index 4f315f041..96593db2c 100644
--- a/src/Core/Grand.Data/Grand.Data.csproj
+++ b/src/Core/Grand.Data/Grand.Data.csproj
@@ -2,10 +2,8 @@
-
-
-
-
+
+
diff --git a/src/Core/Grand.Data/Mongo/BsonUtcDateTimeSerializer.cs b/src/Core/Grand.Data/Mongo/BsonUtcDateTimeSerializer.cs
deleted file mode 100644
index 1e8787d2d..000000000
--- a/src/Core/Grand.Data/Mongo/BsonUtcDateTimeSerializer.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using MongoDB.Bson.Serialization;
-using MongoDB.Bson.Serialization.Serializers;
-
-namespace Grand.Data.Mongo;
-
-public class BsonUtcDateTimeSerializer : DateTimeSerializer
-{
- public override DateTime Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
- {
- return new DateTime(base.Deserialize(context, args).Ticks, DateTimeKind.Utc);
- }
-
- public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, DateTime value)
- {
- var utcValue = new DateTime(value.Ticks, DateTimeKind.Utc);
- base.Serialize(context, args, utcValue);
- }
-}
\ No newline at end of file
diff --git a/src/Core/Grand.Data/Mongo/MongoDBStartupBase.cs b/src/Core/Grand.Data/Mongo/MongoDBStartupBase.cs
index 792463f7f..aa85d9a77 100644
--- a/src/Core/Grand.Data/Mongo/MongoDBStartupBase.cs
+++ b/src/Core/Grand.Data/Mongo/MongoDBStartupBase.cs
@@ -1,5 +1,7 @@
-using Grand.Domain.Media;
+using Grand.Domain;
+using Grand.Domain.Media;
using Grand.SharedKernel;
+using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Options;
@@ -16,14 +18,13 @@ public class MongoDBStartupBase : IStartupBase
///
public void Execute()
{
- BsonSerializer.RegisterSerializer(typeof(DateTime), new BsonUtcDateTimeSerializer());
-
+ BsonSerializer.RegisterSerializer(new GuidSerializer(GuidRepresentation.CSharpLegacy));
BsonSerializer.RegisterSerializer(typeof(Dictionary),
new DictionaryInterfaceImplementerSerializer>(DictionaryRepresentation.ArrayOfArrays));
//global set an equivalent of [BsonIgnoreExtraElements] for every Domain Model
var cp = new ConventionPack {
- new IgnoreExtraElementsConvention(true)
+ new IgnoreExtraElementsConvention(true),
};
ConventionRegistry.Register("ApplicationConventions", cp, t => true);
diff --git a/src/Core/Grand.Domain/Grand.Domain.csproj b/src/Core/Grand.Domain/Grand.Domain.csproj
index b5b322f57..1ba095480 100644
--- a/src/Core/Grand.Domain/Grand.Domain.csproj
+++ b/src/Core/Grand.Domain/Grand.Domain.csproj
@@ -1,7 +1,7 @@
-
+
diff --git a/src/Core/Grand.Domain/ParentEntity.cs b/src/Core/Grand.Domain/ParentEntity.cs
index 11bf167a6..16edb93b8 100644
--- a/src/Core/Grand.Domain/ParentEntity.cs
+++ b/src/Core/Grand.Domain/ParentEntity.cs
@@ -15,5 +15,5 @@ protected ParentEntity()
public string Id {
get => _id;
set => _id = string.IsNullOrEmpty(value) ? UniqueIdentifier.New : value;
- }
+ }
}
\ No newline at end of file
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs
index 84a215c35..e090ae42c 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs
@@ -138,7 +138,7 @@ public async Task ExecuteTest_Import_Insert()
_languageServiceMock.Setup(c => c.GetAllLanguages(It.IsAny(), It.IsAny()))
.Returns(Task.FromResult>(new List()));
_slugServiceMock.Setup(c => c.GetBySlug(It.IsAny()))
- .Returns(Task.FromResult(new EntityUrl { Slug = "slug" }));
+ .Returns(Task.FromResult(new EntityUrl { Slug = "slug", EntityName = "Product" }));
//Act
await _productImportDataObject.Execute(products);
@@ -199,7 +199,7 @@ public async Task ExecuteTest_Import_Update()
.Returns(Task.FromResult>(new List { new() }));
_slugServiceMock.Setup(c => c.GetBySlug(It.IsAny()))
- .Returns(Task.FromResult(new EntityUrl { Slug = "slug" }));
+ .Returns(Task.FromResult(new EntityUrl { Slug = "slug", EntityName = "Product" }));
//Act
await _productImportDataObject.Execute(products);
@@ -253,7 +253,7 @@ public async Task ExecuteTest_Import_Insert_Update()
.Returns(Task.FromResult>(new List { new() }));
_slugServiceMock.Setup(c => c.GetBySlug(It.IsAny()))
- .Returns(Task.FromResult(new EntityUrl { Slug = "slug" }));
+ .Returns(Task.FromResult(new EntityUrl { Slug = "slug", EntityName = "Product" }));
//Act
await _productImportDataObject.Execute(products);
diff --git a/src/Tests/Grand.Data.Tests/MongoDb/MongoDBRepositoryTest.cs b/src/Tests/Grand.Data.Tests/MongoDb/MongoDBRepositoryTest.cs
index 18ecbc289..84aee7d7f 100644
--- a/src/Tests/Grand.Data.Tests/MongoDb/MongoDBRepositoryTest.cs
+++ b/src/Tests/Grand.Data.Tests/MongoDb/MongoDBRepositoryTest.cs
@@ -1,6 +1,9 @@
using Grand.Data.Mongo;
using Grand.Domain;
+using MongoDB.Bson;
+using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Conventions;
+using MongoDB.Bson.Serialization.Serializers;
namespace Grand.Data.Tests.MongoDb;
@@ -10,6 +13,7 @@ public MongoDBRepositoryTest() : base(
DriverTestConfiguration.Client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName),
new AuditInfoProvider())
{
+ BsonSerializer.TryRegisterSerializer(new GuidSerializer(GuidRepresentation.Standard));
var cp = new ConventionPack {
new IgnoreExtraElementsConvention(true)
};