Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Refactor IRepository and repository implementations
KrzysztofPajak99738a083e91
diff --git a/src/Core/Grand.Data/IRepository.cs b/src/Core/Grand.Data/IRepository.csindex 05c7bec12..2590a73ee 100644--- a/src/Core/Grand.Data/IRepository.cs+++ b/src/Core/Grand.Data/IRepository.cs@@ -206,5 +206,5 @@ public interface IRepository<T> where T : BaseEntity/// <summary>/// Gets a table collection/// </summary>- IQueryable<T> TableCollection(string collectionName);+ IQueryable<C> TableCollection<C>() where C : class;}\ No newline at end of filediff --git a/src/Core/Grand.Data/LiteDb/LiteDBRepository.cs b/src/Core/Grand.Data/LiteDb/LiteDBRepository.csindex f179ab7e5..49109a0c8 100644--- a/src/Core/Grand.Data/LiteDb/LiteDBRepository.cs+++ b/src/Core/Grand.Data/LiteDb/LiteDBRepository.cs@@ -1,6 +1,7 @@using Grand.Domain;using Grand.SharedKernel.Attributes;using LiteDB;+using System.Collections;using System.Linq.Expressions;using System.Reflection;@@ -569,9 +570,9 @@ public class LiteDBRepository<T> : IRepository<T> where T : BaseEntity/// <summary>/// Gets a table collection/// </summary>- public virtual IQueryable<T> TableCollection(string collectionName)+ public virtual IQueryable<C> TableCollection<C>() where C : class{- return _database.GetCollection<T>(collectionName).Query().ToEnumerable().AsQueryable();+ return _database.GetCollection<C>(nameof(T)).Query().ToEnumerable().AsQueryable();}#endregiondiff --git a/src/Core/Grand.Data/Mongo/MongoRepository.cs b/src/Core/Grand.Data/Mongo/MongoRepository.csindex fdb3a4847..1a4d6a97c 100644--- a/src/Core/Grand.Data/Mongo/MongoRepository.cs+++ b/src/Core/Grand.Data/Mongo/MongoRepository.cs@@ -443,9 +443,9 @@ public class MongoRepository<T> : IRepository<T> where T : BaseEntity/// <summary>/// Gets a table collection/// </summary>- public virtual IQueryable<T> TableCollection(string collectionName)+ public virtual IQueryable<C> TableCollection<C>() where C : class{- return _collection.Database.GetCollection<T>(collectionName).AsQueryable();+ return _database.GetCollection<C>(typeof(T).Name).AsQueryable();}#endregion