فهرست منبع

Tweaked IStringAutoIncrement interface
Added non-generic IProvider.Query and IProvider.Save functions

frogsoftware 1 سال پیش
والد
کامیت
a9b6ecd2e5
3فایلهای تغییر یافته به همراه20 افزوده شده و 2 حذف شده
  1. 5 1
      InABox.Core/Entity.cs
  2. 7 1
      InABox.Database/IProvider.cs
  3. 8 0
      inabox.database.sqlite/SQLiteProvider.cs

+ 5 - 1
InABox.Core/Entity.cs

@@ -345,10 +345,14 @@ namespace InABox.Core
     {
     }
 
-    public interface IStringAutoIncrement<T> : IAutoIncrement<T, string>
+    public interface IStringAutoIncrement
     {
         string AutoIncrementFormat();
     }
+    
+    public interface IStringAutoIncrement<T> : IAutoIncrement<T, string>, IStringAutoIncrement
+    {
+    }
 
     /// <summary>
     /// Used to flag an entity as exhibiting the properties of a ManyToMany relationship, allowing PRS to auto-generate things like grids and datamodels based on

+ 7 - 1
InABox.Database/IProvider.cs

@@ -19,7 +19,11 @@ namespace InABox.Database
 
         IEnumerable<object[]> List<T>(Filter<T>? filter = null, Columns<T>? columns = null, SortOrder<T>? sort = null) where T : Entity, new();
         
-        CoreTable Query<T>(Filter<T>? filter = null, Columns<T>? columns = null, SortOrder<T>? sort = null, int top = int.MaxValue, bool log = false, bool distinct = false) where T : Entity, new();
+        CoreTable Query<T>(Filter<T>? filter = null, Columns<T>? columns = null, SortOrder<T>? sort = null, 
+            int top = int.MaxValue, bool log = false, bool distinct = false) where T : Entity, new();
+        
+        CoreTable Query(Type type, IFilter filter = null, IColumns columns = null, ISortOrder sort = null, 
+            int top = int.MaxValue, bool log = false, bool distinct = false);
         
         /// <summary>
         /// Same as <see cref="Query{T}(Filter{T}, Columns{T}, SortOrder{T}, int, bool)"/>, but only for deleted items
@@ -38,6 +42,8 @@ namespace InABox.Database
         void Save<T>(T entity) where T : Entity;
         void Save<T>(IEnumerable<T> entities) where T : Entity;
 
+        void Save(Type type, IEnumerable<Entity> entities, bool addDelete = false);
+
         void Delete<T>(T entity, string userID) where T : Entity, new();
         void Delete<T>(IEnumerable<T> entities, string userID) where T : Entity, new();
 

+ 8 - 0
inabox.database.sqlite/SQLiteProvider.cs

@@ -2466,6 +2466,9 @@ namespace InABox.Database.SQLite
         private CoreTable DoQuery<T>(Filter<T>? filter, Columns<T>? columns, SortOrder<T>? sort, int top, bool log, bool distinct)
             where T : Entity, new() => DoQueryNonGeneric(typeof(T), filter, columns, sort, top, log, distinct);
 
+        public CoreTable Query(Type type, IFilter filter, IColumns columns, ISortOrder sort, int top, bool log, bool distinct)
+            => DoQueryNonGeneric(type, filter, columns, sort, top, log, distinct);
+        
         public CoreTable Query<T>(Filter<T>? filter = null, Columns<T>? columns = null, SortOrder<T>? sort = null, int top = int.MaxValue, bool log = false, bool distinct = false) 
             where T : Entity, new()
         {
@@ -2596,6 +2599,9 @@ namespace InABox.Database.SQLite
         private void OnSave<T>(IEnumerable<T> entities, bool addDelete = false) where T : Entity
             => OnSaveNonGeneric(typeof(T), entities, addDelete);
 
+        public void Save(Type type, IEnumerable<Entity> entities, bool addDelete = false)
+            => OnSaveNonGeneric(type, entities, addDelete);
+
         public static bool CanSave<T>()
         {
             if (DbFactory.IsReadOnly)
@@ -2610,6 +2616,8 @@ namespace InABox.Database.SQLite
             return true;
         }
 
+
+        
         public void Save<T>(IEnumerable<T> entities) where T : Entity
         {
             if (!CanSave<T>())