Example #1
0
        /// <summary>
        /// Initializes a new instance of the UnQLite class without UnQLiteException.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">
        ///  fileName is null.
        /// </exception>
        public static UnQLiteResultCode TryOpen(string fileName, UnQLiteOpenModel model, out UnQLite unqlite)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }

            unqlite = null;
            IntPtr            pDB;
            UnQLiteResultCode code = UnsafeNativeMethods.unqlite_open(out pDB, fileName, model);

            if (code == UnQLiteResultCode.Ok)
            {
                unqlite = new UnQLite(pDB);
            }
            return(code);
        }
Example #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="path"></param>
 /// <param name="mode"></param>
 public UnQEntitybase(string path, UnQMode mode)
 {
     if (mode == UnQMode.Open)
     {
         if (!System.IO.File.Exists(path))
         {
             throw new Exception($"tsdb config '{path}' not exists");
         }
         unqlite = new UnQLite(path, UnQLiteOpenModel.ReadWrite);
     }
     if (mode == UnQMode.Override)
     {
         if (System.IO.File.Exists(path))
         {
             System.IO.File.Delete(path);
         }
         unqlite = new UnQLite(path, UnQLiteOpenModel.Create);
     }
     else
     {
         unqlite = new UnQLite(path, UnQLiteOpenModel.Create);
     }
     this.Entities = new Dictionary <string, UnQRecord>();
 }
Example #3
0
 internal UnQLiteTransaction(UnQLite unqlite)
 {
     unQLite_ = unqlite;
     unQLite_.isAutoCommit_ = false;
 }
Example #4
0
 /// <summary>
 /// create a database in memory
 /// </summary>
 public UnQEntitybase()
 {
     unqlite       = new UnQLite(inmemory, UnQLiteOpenModel.Create);
     this.Entities = new Dictionary <string, UnQRecord>();
 }