|
@@ -66,10 +66,38 @@ namespace InABox.Clients
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private static IClient<TEntity> CheckClient<TEntity>() where TEntity : Entity, IRemotable, IPersistent, new()
|
|
|
+ {
|
|
|
+ return ClientFactory.CreateClient<TEntity>();
|
|
|
+ }
|
|
|
+
|
|
|
public static CoreTable Query<TEntity>(Filter<TEntity>? filter = null, Columns<TEntity>? columns = null, SortOrder<TEntity>? orderby = null)
|
|
|
where TEntity : Entity, IRemotable, IPersistent, new()
|
|
|
{
|
|
|
- return new Client<TEntity>().Query(filter, columns, orderby);
|
|
|
+ return CheckClient<TEntity>().Query(filter, columns, orderby);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void Save<TEntity>(TEntity entity, string auditNote)
|
|
|
+ where TEntity : Entity, IRemotable, IPersistent, new()
|
|
|
+ {
|
|
|
+ CheckClient<TEntity>().Save(entity, auditNote);
|
|
|
+ }
|
|
|
+ public static void Save<TEntity>(IEnumerable<TEntity> entities, string auditNote)
|
|
|
+ where TEntity : Entity, IRemotable, IPersistent, new()
|
|
|
+ {
|
|
|
+ CheckClient<TEntity>().Save(entities, auditNote);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void Delete<TEntity>(TEntity entity, string auditNote)
|
|
|
+ where TEntity : Entity, IRemotable, IPersistent, new()
|
|
|
+ {
|
|
|
+ CheckClient<TEntity>().Delete(entity, auditNote);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void Delete<TEntity>(IEnumerable<TEntity> entities, string auditNote)
|
|
|
+ where TEntity : Entity, IRemotable, IPersistent, new()
|
|
|
+ {
|
|
|
+ CheckClient<TEntity>().Delete(entities, auditNote);
|
|
|
}
|
|
|
|
|
|
public static void QueryMultiple(
|
|
@@ -438,9 +466,10 @@ namespace InABox.Clients
|
|
|
{
|
|
|
using var timer = new Profiler<TEntity>(false);
|
|
|
CheckSupported();
|
|
|
- if (entities.Any())
|
|
|
- _client.Save(entities, auditnote);
|
|
|
- timer.Log(entities.Count());
|
|
|
+ var items = entities.AsArray();
|
|
|
+ if (items.Any())
|
|
|
+ _client.Save(items, auditnote);
|
|
|
+ timer.Log(items.Length);
|
|
|
}
|
|
|
catch (RequestException e)
|
|
|
{
|
|
@@ -455,8 +484,9 @@ namespace InABox.Clients
|
|
|
{
|
|
|
var timer = new Profiler<TEntity>(false);
|
|
|
CheckSupported();
|
|
|
- if (entities.Any())
|
|
|
- _client.Save(entities, auditnote, (i, e) =>
|
|
|
+ var items = entities.AsArray();
|
|
|
+ if (items.Any())
|
|
|
+ _client.Save(items, auditnote, (i, e) =>
|
|
|
{
|
|
|
timer.Dispose(i.Count());
|
|
|
callback?.Invoke(i, e);
|
|
@@ -506,14 +536,15 @@ namespace InABox.Clients
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void Delete(IList<TEntity> entities, string auditnote)
|
|
|
+ public void Delete(IEnumerable<TEntity> entities, string auditnote)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
using var timer = new Profiler<TEntity>(false);
|
|
|
CheckSupported();
|
|
|
- _client.Delete(entities, auditnote);
|
|
|
- timer.Log(entities.Count());
|
|
|
+ var items = entities.AsArray();
|
|
|
+ _client.Delete(items, auditnote);
|
|
|
+ timer.Log(items.Length);
|
|
|
}
|
|
|
catch (RequestException e)
|
|
|
{
|
|
@@ -522,15 +553,16 @@ namespace InABox.Clients
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void Delete(IList<TEntity> entities, string auditnote, Action<IList<TEntity>, Exception?> callback)
|
|
|
+ public void Delete(IEnumerable<TEntity> entities, string auditnote, Action<IList<TEntity>, Exception?> callback)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
var timer = new Profiler<TEntity>(false);
|
|
|
CheckSupported();
|
|
|
- _client.Delete(entities, auditnote, (i, e) =>
|
|
|
+ var items = entities.AsArray();
|
|
|
+ _client.Delete(items, auditnote, (i, e) =>
|
|
|
{
|
|
|
- timer.Dispose(entities.Count());
|
|
|
+ timer.Dispose(i.Count);
|
|
|
callback?.Invoke(i, e);
|
|
|
});
|
|
|
}
|