Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        SqliteInit.InitSqlite();


        FieldLister lister = new FieldLister();

        UserData[] data = new UserData[2];

        data[0]                  = new UserData();
        data[0].ID               = 1;
        data[0].Name             = "Tarou";
        data[0].Hoge             = "fuga";
        data[0].Age              = 32;
        data[0].LastUpdated      = new DateTime(2013, 4, 1);
        data[0].NestedClass.Fuga = "bbbb";
        data[0].NestedClass.Hoge = 23;

        data[1]             = new UserData();
        data[1].ID          = 2;
        data[1].Name        = "Jirou";
        data[1].Hoge        = "wahoo";
        data[1].Age         = 11;
        data[1].AddressData = "aaaaa";
        data[1].LastUpdated = new DateTime(2013, 5, 1);

        Write(data[0].ToString());


        var info = lister.ListUp <UserData>();

        Write(info.ToString());

        var    sqlMaker = new SQLMaker();
        string insert   = sqlMaker.GenerateInsertSQL(info, data[0]);
        string update   = sqlMaker.GenerateUpdateSQL(info, data[0]);

        Write("Insert = {0}", insert);
        Write("Update = {0}", update);

        DBMapper mapper = new DBMapper(SqliteInit.Evolution.Database);

        mapper.UpdateOrInsertAll(data);

        UserData[] fromDb = mapper.Read <UserData>("SELECT * FROM UserData;");
        Write(fromDb[0].ToString());
        Write(fromDb[1].ToString());


        JSONMapper jsonMapper = new JSONMapper();

        string json = jsonMapper.Write <UserData>(fromDb);

        UserData[] fromJson = jsonMapper.Read <UserData>(json);

        Write("Json = {0}", json);

        Write(fromJson[0].ToString());
        Write(fromJson[1].ToString());
    }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        SqliteInit.InitSqlite();

        FieldLister lister = new FieldLister();

        UserData[] data = new UserData[2];

        data[0] = new UserData();
        data[0].ID = 1;
        data[0].Name = "Tarou";
        data[0].Hoge = "fuga";
        data[0].Age = 32;
        data[0].LastUpdated = new DateTime(2013,4,1);
        data[0].NestedClass.Fuga = "bbbb";
        data[0].NestedClass.Hoge = 23;

        data[1] = new UserData();
        data[1].ID = 2;
        data[1].Name = "Jirou";
        data[1].Hoge = "wahoo";
        data[1].Age = 11;
        data[1].AddressData = "aaaaa";
        data[1].LastUpdated = new DateTime(2013,5,1);

        Debug.Log(data[0]);

        var info = lister.ListUp<UserData>();

        Debug.Log(info);

        var sqlMaker = new SQLMaker();
        string insert = sqlMaker.GenerateInsertSQL(info,data[0]);
        string update = sqlMaker.GenerateUpdateSQL(info,data[0]);

        Debug.Log("Insert = " + insert);
        Debug.Log("Update = " + update);

        DBMapper mapper = new DBMapper(SqliteInit.Evolution.Database);

        mapper.UpdateOrInsertAll(data);

        UserData[] fromDb = mapper.Read<UserData>("SELECT * FROM UserData;");
        Debug.Log(fromDb[0]);
        Debug.Log(fromDb[1]);

        JSONMapper jsonMapper = new JSONMapper();

        string json = jsonMapper.Write<UserData>(fromDb);
        UserData[] fromJson = jsonMapper.Read<UserData>(json);

        Debug.Log("Json = " + json);

        Debug.Log(fromJson[0]);
        Debug.Log(fromJson[1]);
    }
    // Use this for initialization
    void Start()
    {
                #if UNITY_ANDROID
        MyLibs.InitializeSQLCipher();
                #endif

        if (dataObjects.Length < 1)
        {
            Write("No data to write database!");
            return;
        }

        ORMSQLiteInit.InitSqlite(dbFile, dbDirectory, password);
        Write("Open Database at " + ORMSQLiteInit.pathDB);

        FieldLister lister = new FieldLister();

        Write(dataObjects[0].ToString());
        var info = lister.ListUp <UserData>();

        Write(info.ToString());
        string insert = SQLMaker.GenerateInsertSQL(info, dataObjects[0]);
        string update = SQLMaker.GenerateUpdateSQL(info, dataObjects[0]);

        Write("Insert = {0}", insert);
        Write("Update = {0}", update);

        DBMapper mapper = new DBMapper(ORMSQLiteInit.Evolution.Database);
        mapper.UpdateOrInsertAll(dataObjects);

        UserData[] fromDb = mapper.Read <UserData>("SELECT * FROM UserData;");
        Write(fromDb[0].ToString());
        Write(fromDb[1].ToString());

        JSONMapper jsonMapper = new JSONMapper();
        string     json       = jsonMapper.Write <UserData>(fromDb);
        UserData[] fromJson   = jsonMapper.Read <UserData>(json);

        Write("Json = {0}", json);
        Write(fromJson[0].ToString());
        Write(fromJson[1].ToString());

                #if UNITY_ANDROID
        MyLibs.ToastMessage("SQLCipher Done");
                #endif
    }