SQLite c# : How to save and retrieve custom object in sqlite BLOB datatype? -


there custom object(ex company) , list of custom object (ex employee) needs saved in blob datatype, below piece of code have tried without success. have tried dbtype.binary did not workout.

below piece of insert query :

sql_cmd.parameters.add("@company", dbtype.byte);  sql_cmd.parameters["@company"].value = (company)root.company;   sql_cmd.parameters.add("@employees", dbtype.byte); sql_cmd.parameters["@employees"].value = ((list< employee >))root.employeelist; 

exception :

system.formatexception unhandled user code. message=input string not in correct format. 


below associated classes

 class company     {         public string id { get; set; }         public string name { get; set; }         public list<package> packages { get; set; }         public string description { get; set; }     }   class employee     {         public string id { get; set; }         public string name { get; set; }         public object description { get; set; }         public address address { get; set; }         public contact contact { get; set; }         public string enterpriseid { get; set; }         public object createddate { get; set; }         public object modifieddate { get; set; } } 

if using sqlite.net-pcl can store entire object. not in blob type. must have separate table 'package' objects. can add company id property package object can find items easily. has cleaner syntax.

db.createtable<company>(); db.createtable<package>();  db.insertall(alistofcompanies); 

Comments