From d17422d64636d5f0073b1fe4a59b75857c726a30 Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Thu, 10 Oct 2024 22:12:46 +0330 Subject: [PATCH] fix marten --- .../appsettings.DevelopmentVesmeh.json | 2 +- Netina.Api/Netina.Api.csproj | 4 +-- .../Configurations/ServiceExtensions.cs | 2 +- Netina.Common/Models/Entity/MartenEntity.cs | 34 +++++++++---------- .../Entities/Products/Product.Aggregate.cs | 6 ++-- .../Marten/MartenRepository.cs | 7 ++-- 6 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Netina.Api/AppSettings/appsettings.DevelopmentVesmeh.json b/Netina.Api/AppSettings/appsettings.DevelopmentVesmeh.json index 410ba95..afa4653 100644 --- a/Netina.Api/AppSettings/appsettings.DevelopmentVesmeh.json +++ b/Netina.Api/AppSettings/appsettings.DevelopmentVesmeh.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "PostgresServer": "Host=185.220.227.39;Username=vesmmehAgent;Password=g05CTjK358Vx3Eoc9satsWyVwo+15UmsA2dnCrZRUYh1pLTe;Database=NetinaShopDB;Application Name=NetinaShopApi", + "PostgresServer": "Host=185.220.227.29;Username=vesmmehAgent;Password=g05CTjK358Vx3Eoc9satsWyVwo+15UmsA2dnCrZRUYh1pLTe;Database=NetinaShopDB;Application Name=NetinaShopApi", "Postgres": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopDB", "MartenDB": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopMartenDB" }, diff --git a/Netina.Api/Netina.Api.csproj b/Netina.Api/Netina.Api.csproj index f24c487..dd2cbfc 100644 --- a/Netina.Api/Netina.Api.csproj +++ b/Netina.Api/Netina.Api.csproj @@ -6,8 +6,8 @@ enable true Linux - 1.5.17.26 - 1.5.17.26 + 1.5.18.27 + 1.5.18.27 diff --git a/Netina.Api/WebFramework/Configurations/ServiceExtensions.cs b/Netina.Api/WebFramework/Configurations/ServiceExtensions.cs index eb04e9d..977c174 100644 --- a/Netina.Api/WebFramework/Configurations/ServiceExtensions.cs +++ b/Netina.Api/WebFramework/Configurations/ServiceExtensions.cs @@ -72,7 +72,7 @@ public static class ServiceExtensions serviceCollection.AddDbContextFactory(options => { options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking); - options.UseNpgsql(Configuration.GetConnectionString("PostgresServer"), b => b.MigrationsAssembly("Netina.Repository")) + options.UseNpgsql(Configuration.GetConnectionString("Postgres"), b => b.MigrationsAssembly("Netina.Repository")) .UseProjectAssembly(typeof(ApplicationUser).Assembly); //options.EnableServiceProviderCaching(true); diff --git a/Netina.Common/Models/Entity/MartenEntity.cs b/Netina.Common/Models/Entity/MartenEntity.cs index d45aa3b..7e8c107 100644 --- a/Netina.Common/Models/Entity/MartenEntity.cs +++ b/Netina.Common/Models/Entity/MartenEntity.cs @@ -19,23 +19,23 @@ public class MartenEntity : IMartenEntity - public bool Equals(ApiEntity other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Id.Equals(other.Id); - } + //public bool Equals(ApiEntity other) + //{ + // if (ReferenceEquals(null, other)) return false; + // if (ReferenceEquals(this, other)) return true; + // return Id.Equals(other.Id); + //} - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((ApiEntity)obj); - } + //public override bool Equals(object obj) + //{ + // if (ReferenceEquals(null, obj)) return false; + // if (ReferenceEquals(this, obj)) return true; + // if (obj.GetType() != this.GetType()) return false; + // return Equals((ApiEntity)obj); + //} - public override int GetHashCode() - { - return Id.GetHashCode(); - } + //public override int GetHashCode() + //{ + // return Id.GetHashCode(); + //} } \ No newline at end of file diff --git a/Netina.Domain/Entities/Products/Product.Aggregate.cs b/Netina.Domain/Entities/Products/Product.Aggregate.cs index 927cac2..8d4b557 100644 --- a/Netina.Domain/Entities/Products/Product.Aggregate.cs +++ b/Netina.Domain/Entities/Products/Product.Aggregate.cs @@ -1,4 +1,6 @@ -namespace Netina.Domain.Entities.Products; +using System.Net; + +namespace Netina.Domain.Entities.Products; public partial class Product { @@ -12,7 +14,7 @@ public partial class Product Guid brandId, Guid categoryId, Guid authorId) { - var slug = StringExtensions.GetSlug(persianName); + var slug = WebUtility.UrlEncode(persianName.Replace(' ', '-')); return new Product( persianName, englishName, diff --git a/Netina.Infrastructure/Marten/MartenRepository.cs b/Netina.Infrastructure/Marten/MartenRepository.cs index d970213..263f93c 100644 --- a/Netina.Infrastructure/Marten/MartenRepository.cs +++ b/Netina.Infrastructure/Marten/MartenRepository.cs @@ -20,11 +20,12 @@ public class MartenRepository(IDocumentStore documentStore, ICurr public async Task> GetEntitiesAsync(int page, int count, CancellationToken cancellation) { await using var session = documentStore.QuerySession(); - var entities = await session - .Query() + var schema = session.DocumentStore.Options.Schema; + var entities = session + .Query($"select data from {schema.For()} ORDER BY \"mt_last_modified\" DESC " ) .Skip(page * count) .Take(count) - .ToListAsync(cancellation); + .ToList(); return entities.ToList(); }