static void Main(string[] args) { string dbFile = "test.db"; OdbFactory.Delete(dbFile); User user3 = new User() { Id = Guid.Empty, Name = "test3", Password = "******", Email = "*****@*****.**" }; using (var factory = OdbFactory.Open(dbFile)) { user3.PropertiesData["Age"] = 18; user3.PropertiesData["Address"] = "dghfhfg"; user3.PropertiesData["IsMarried"] = true; factory.Store(user3); List<User> users = new List<User>(); for (int i = 0; i < 10; i++) { User tempUser = new User() { Id = Guid.NewGuid(), Name = "test" + i, Password = "******" + i, Email = i + "*****@*****.**" }; tempUser.PropertiesData["Age"] = i + 24; tempUser.PropertiesData["Address"] = Guid.NewGuid().ToString(); tempUser.PropertiesData["IsMarried"] = true; users.Add(tempUser); } factory.Store(users); } using (var factory = OdbFactory.Open(dbFile)) { var result = factory.AsQueryable<User>().ToList(); user3.Name = "FFFFFFF"; var dbUser = factory.AsQueryable<User>().Where(er => er.Id == user3.Id).FirstOrDefault(); if (dbUser != null) { factory.Delete(dbUser); } factory.Store(user3); result = factory.QueryAndExecute<User>().ToList(); } Console.ReadLine(); }
private static void JsonTest() { JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); DataContractJsonSerializer dcSerializer = new DataContractJsonSerializer(typeof(User)); User user1 = new User() { Id = Guid.NewGuid(), Name = "test1", Password = "******", Email = "*****@*****.**" }; Console.WriteLine(jsSerializer.Serialize(user1)); User user2 = new User() { Id = Guid.NewGuid(), Name = "test2", Password = "******", Email = "*****@*****.**" }; user2.PropertiesBag.Test = "Hello"; Console.WriteLine(jsSerializer.Serialize(user2)); User user3 = new User() { Id = Guid.NewGuid(), Name = "test3", Password = "******", Email = "*****@*****.**" }; user3.PropertiesData["Age"] = 18; user3.PropertiesData["Address"] = "dghfhfg"; user3.PropertiesData["IsMarried"] = true; Console.WriteLine(jsSerializer.Serialize(user3)); List<User> users = new List<User>(); for (int i = 0; i < 10; i++) { User tempUser = new User() { Id = Guid.NewGuid(), Name = "test" + i, Password = "******" + i, Email = i + "*****@*****.**" }; tempUser.PropertiesData["Age"] = i + 24; tempUser.PropertiesData["Address"] = Guid.NewGuid().ToString(); tempUser.PropertiesData["IsMarried"] = true; users.Add(tempUser); } string jsonUsers = jsSerializer.Serialize(users); Console.WriteLine(jsonUsers); var deserializeUsers = jsSerializer.Deserialize(jsonUsers, typeof(List<User>)); }