You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usingIBoxDB.LocalServer;usingIBoxDB.LocalServer.IO;publicclassAppServer:LocalDatabaseServer{privatestaticAppServerserver=newAppServer();publicstaticIDatabaseDB(longaddress){returnserver.GetInstance(address);}abstractclassConfig:BoxFileStreamConfig{publicConfig():base(){CacheLength=MB(512);//1024L*1024L*512LFileIncSize=(int)MB(4);//Thread, default is 4ReadStreamCount=8;//set equal to 1 in small device.//ReadStreamCount = 1; }}classMainConfig:Config{publicMainConfig():base(){EnsureTable<Member>("Member","Id");//set Max-Length = 20, String default is 32EnsureIndex<Member>("Member","Name(20)");EnsureTable<Product>("Product","Type","UID");}}classInventoryConfig:Config{publicInventoryConfig():base(){EnsureTable<Item>("Item","Id");}}protectedoverrideDatabaseConfigBuildDatabaseConfig(longaddress){switch(address){case1L:returnnewMainConfig();case2L:returnnewInventoryConfig();default:returnnull;}}}voidAnywhere1(){varauto=AppServer.DB(1L).Get();auto.Insert("Member",newMember());}voidAnywhere2(){vardb=AppServer.DB(2L);using(varbox=db.Cube()){box["Item"].Insert(newItem());CommitResultcr=box.Commit();}}voidOnApplicationClose(){AppServer.server.Dispose();}
if(GUI.Button(newRect(0,50,Screen.width/2,50),"Save")){Application.ExternalEval("FS.syncfs(false, function (err) {});");}
Cache Only & Heat Up
DBdb=newDB(DB.CacheOnlyArg);//Using Thread to heat engine up Before Application.Start()//System.Threading.Tasks.Task.Run((Action)Hot);newThread(()=>{Hot();}).Start();staticAutoBoxauto;publicstaticvoidHot(){vardb=newDB();db.GetConfig().EnsureTable<Item>("Item","Time","Gid");auto=db.Open();auto.Insert("Item",newItem());auto.Select("from Item");}
Complex Search, Region Control
//use a simple query to control search regionbox.Select<User>("from User where Version>? limit 0,1000",last)//with a complex query to filter data.Where((u)=>{if(u...)if(u...)returnu.Time>dt;});
DB.root(path);
DBdb = newDB();
DatabaseConfigconfig = db.getConfig();
//mobiles have only 256MB memory, set Cache to 16 or 32MB.config.CacheLength = config.mb(32);
config.FileIncSize = 1024 * 64;
config.ReadStreamCount = 1;
App.auto = db.open();
Dataset Combiner
//combining datasetpublicclassCombiner<T>{HashSet<object>ids;Func<T,object>getid;List<T>results;publicCombiner(Func<T,object>getid){this.getid=getid;this.ids=newHashSet<object>();this.results=newList<T>();}publicvoidAdd(IEnumerable<T>result){foreach(vartinresult){if(getid!=null){varid=getid(t);if(!ids.Add(id)){continue;}}results.Add(t);}}publicList<T>Select(){returnresults;}publicIEnumerable<T>OrderBy<TKey>(Func<T,TKey>keySelector){returnEnumerable.OrderBy(results,keySelector);}publicIEnumerable<IGrouping<TKey,T>>GroupBy<TKey>(Func<T,TKey>keySelector){returnEnumerable.GroupBy(results,keySelector);}}classItem{publiclongId;publicstringName;publicstringLocation;}staticvoidMain(string[]args){DBdb=newDB();db.GetConfig().EnsureTable<Item>("Item","Id").EnsureIndex<Item>("Item","Name").EnsureIndex<Item>("Item","Location");AutoBoxauto=db.Open();using(Boxbox=auto.Cube()){Combiner<Item>combiner=newCombiner<Item>(t =>t.Id);combiner.Add(box.Select<Item>("from Item where Name==?","Name4"));combiner.Add(box.Select<Item>("from Item where Id==?",1L));combiner.Add(box.Select<Item>("from Item where Id==?",2L));combiner.Add(box.Select<Item>("from Item where Location==?","Location6"));foreach(vartincombiner.OrderBy(t =>t.Id)){Console.WriteLine(DB.ToString(t));}}}
Supported Types
.NET
bool
char
byte
sbyte
short
ushort
int
uint
long
ulong
float
double
decimal
DateTime
Guid
bool?
char?
byte?
sbyte?
short?
ushort?
int?
uint?
long?
ulong?
float?
double?
decimal?
DateTime?
Guid?
string
//non-indexable
Dictionary<string, object>
MemoryStream
byte[]
string[]
JAVA
boolean
Boolean
byte
Byte
char
Character
short
Short
int
Integer
long
Long
float
Float
double
Double
UUID
Date
//dynamic length
BigDecimal
BigInteger
String
//non-indexable
HashMap<String,Object>
MemoryStream
byte[]
Object[]
Indexing for byte[] or others,
using ToBase64String(byte[]) Converts it to String.