Geeks With Blogs

News profile for Ken Tucker at Stack Overflow, Q&A for professional and enthusiast programmers
Ken Tucker Adventures in .Net

Lex.DB is an object database that can be used in Windows Store and Windows Phone apps.   This is a fast free alternative to SQLite.


To learn more about Lex.DB see Lex's blog



In my case I wanted to include a database that already had data in it with a windows phone 8 app I created.



List<AutoMobileInformation.AutoMobileCodes> lstComplete = 
                        new List<AutoMobileInformation.AutoMobileCodes>();
using (var db = new DbInstance("auto codes"))
     db.Map<AutoMobileInformation.AutoMobileCodes>().Automap(i => i.Id)
                       .WithIndex("Code", i => i.Code).WithIndex("Manufacture", i => i.Manufacture);
     lstComplete = db.LoadAll<AutoMobileInformation.AutoMobileCodes>().ToList();
     if (lstComplete.Count == 0)
         var lex = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Lex.Db"
         var auto = await lex.CreateFolderAsync("auto codes"
         StorageFile seedFile1 = await StorageFile.GetFileFromPathAsync(
         StorageFile seedFile2 = await StorageFile.GetFileFromPathAsync(
         await seedFile1.CopyAsync(auto, @"AutoMobileCodes.index"
         await seedFile2.CopyAsync(auto, @""
In the code first we create an instance of the database.  The we add an index to the database.  Then we check and see if there is any data in the database.  
If there is not I replace the Index and Data file in isolated storage with files that have data.
Posted on Saturday, June 7, 2014 10:12 AM Windows Phone , Windows Store , Lex.DB | Back to top

Comments on this post: Seeding a Lex.DB

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Ken Tucker | Powered by: