Skip to content

Commit

Permalink
Refactor IDatabaseContext and update implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofPajak committed Nov 3, 2024
1 parent 1aadb36 commit d8a5ec5
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 20 deletions.
5 changes: 1 addition & 4 deletions src/Core/Grand.Data/IDatabaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ public interface IDatabaseContext
bool InstallProcessCreateTable { get; }
bool InstallProcessCreateIndex { get; }
void SetConnection(string connectionString);
Task<bool> DatabaseExist();
IQueryable<T> Table<T>(string collectionName);
Task<bool> DatabaseExist();
Task CreateTable(string name, string collation);
Task DeleteTable(string name);

Task CreateIndex<T>(IRepository<T> repository, OrderBuilder<T> orderBuilder, string indexName, bool unique = false)
where T : BaseEntity;

Task DeleteIndex<T>(IRepository<T> repository, string indexName) where T : BaseEntity;
}
8 changes: 0 additions & 8 deletions src/Core/Grand.Data/LiteDb/LiteDBContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ public void SetConnection(string connectionString)
public bool InstallProcessCreateTable => false;
public bool InstallProcessCreateIndex => true;

public IQueryable<T> Table<T>(string collectionName)
{
if (string.IsNullOrEmpty(collectionName))
throw new ArgumentNullException(nameof(collectionName));

return _database.GetCollection<T>(collectionName).FindAll().AsQueryable();
}

public async Task<bool> DatabaseExist()
{
return await Task.FromResult(_database.CollectionExists(nameof(GrandNodeVersion)));
Expand Down
8 changes: 0 additions & 8 deletions src/Core/Grand.Data/Mongo/MongoDBContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ public void SetConnection(string connectionString)
public bool InstallProcessCreateTable => true;
public bool InstallProcessCreateIndex => true;

public IQueryable<T> Table<T>(string collectionName)
{
if (string.IsNullOrEmpty(collectionName))
throw new ArgumentNullException(nameof(collectionName));

return _database.GetCollection<T>(collectionName).AsQueryable();
}

public async Task<bool> DatabaseExist()
{
if (string.IsNullOrEmpty(_connectionString))
Expand Down

0 comments on commit d8a5ec5

Please sign in to comment.