Fix GraphQL Implementation and also UI Playground and add supports for Oracle Provider using EF Core ...
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -12,29 +13,48 @@ namespace xDataService.Providers
|
||||
public abstract class XBaseDbSeeder<TEntity, TKey> : IXBaseDbSeeder<TEntity, TKey>
|
||||
where TEntity : XBaseEntity<TKey>
|
||||
{
|
||||
//
|
||||
#region Properties ...
|
||||
/// <summary>
|
||||
/// Holds Entity Name ...
|
||||
/// </summary>
|
||||
public string Entity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds Database Name ...
|
||||
/// </summary>
|
||||
public string Database { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Repository Service for Data Manipulation ...
|
||||
/// </summary>
|
||||
public IXBaseRepository<TEntity, TKey> Repository { get; }
|
||||
|
||||
/// <summary>
|
||||
/// DataServiceConfiguration ...
|
||||
/// </summary>
|
||||
public XDataServiceConfiguration DataServiceConfiguration { get; }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Constructor ...
|
||||
public XBaseDbSeeder(
|
||||
string entity,
|
||||
string database,
|
||||
IXBaseRepository<TEntity, TKey> repository,
|
||||
XDataServiceConfiguration dataServiceConfiguration
|
||||
)
|
||||
{
|
||||
//
|
||||
this.Entity = entity;
|
||||
this.Database = database;
|
||||
this.Repository = repository;
|
||||
this.DataServiceConfiguration = dataServiceConfiguration;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public async Task Seed()
|
||||
{
|
||||
//
|
||||
var entityName = nameof(TEntity);
|
||||
|
||||
//
|
||||
// Validate Seed ...
|
||||
var isValid =
|
||||
@@ -45,7 +65,7 @@ namespace xDataService.Providers
|
||||
db.Key == Database &&
|
||||
db.Value.SeedItems
|
||||
.Any(si =>
|
||||
si.Key == entityName &&
|
||||
si.Key == Entity &&
|
||||
si.Value.HasChild()));
|
||||
if (!isValid)
|
||||
{
|
||||
@@ -56,7 +76,7 @@ namespace xDataService.Providers
|
||||
// Extract Seeding Items ...
|
||||
var seedItems = DataServiceConfiguration
|
||||
.Databases[Database]
|
||||
.SeedItems[entityName]
|
||||
.SeedItems[Entity]
|
||||
.ToList();
|
||||
foreach (var item in seedItems)
|
||||
{
|
||||
@@ -64,8 +84,9 @@ namespace xDataService.Providers
|
||||
try
|
||||
{
|
||||
//
|
||||
// Try to convert Item to Entity ...
|
||||
var entity = ((object)item).FromDynamicObject<TEntity>();
|
||||
var entity = item
|
||||
.ToJSON()
|
||||
.FromJSON<TEntity>();
|
||||
|
||||
//
|
||||
// Check Item Exists or not ...
|
||||
@@ -100,7 +121,10 @@ namespace xDataService.Providers
|
||||
if (!isExist)
|
||||
{
|
||||
//
|
||||
exists = await Repository.AddAsync(entity);
|
||||
exists = await Repository.AddAsync(
|
||||
item: entity,
|
||||
saveChanges: true
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user