static void TestChangeDb(DataAccessor dal, ITableMappable mapper) { Console.WriteLine("\nTest change Db"); string dbPath = Directory.GetCurrentDirectory(); dbPath = Path.Combine(dbPath, "Blogging_1.db"); string conStr = $"Data Source={dbPath}"; Console.WriteLine("Org Data:"); var list = dal.GetAll <Blog>().ToList(); PrintData(list); dal.ChangeDataBase(conStr); Console.WriteLine("Changed Data:"); list = dal.GetAll <Blog>().ToList(); PrintData(list); }
static void BasicUsage(DataAccessor dal) { Console.WriteLine("\nTest BasicUsage"); long newId = 2; // Add Console.WriteLine("Test Add"); Console.WriteLine("Org data:"); var list = dal.GetAll <Blog>().ToList(); PrintData(list); Blog newData = new Blog { BlogId = newId, Rating = 666, Url = "https://blog.test.com" }; dal.AddRecord(newData); dal.Save(); Console.WriteLine("New data:"); list = dal.GetAll <Blog>().ToList(); PrintData(list); Console.WriteLine(); // update Blog target = dal.GetByID <Blog>(newId); Console.WriteLine("Test Update"); target.Url = "https://newurl.test.com"; dal.Update(target); dal.Save(); list = dal.GetAll <Blog>().ToList(); PrintData(list); Console.WriteLine(); // delete Console.WriteLine("Test Delete"); dal.Delete(target); dal.Save(); list = dal.GetAll <Blog>().ToList(); PrintData(list); Console.WriteLine(); }
static void TestChangeTable(DataAccessor dal, ITableMappable mapper) { DateTime sept = DateTime.Parse("2019-09-05"); DateTime oct = DateTime.Parse("2019-10-05"); dal.ChangeMappingTable(typeof(Post), mapper, oct); List <Post> octData = dal.GetAll <Post>().ToList(); Console.WriteLine("Oct. data"); foreach (Post item in octData) { Console.WriteLine(item); } dal.ChangeMappingTable(typeof(Post), mapper, sept); List <Post> septData = dal.GetAll <Post>().ToList(); Console.WriteLine("Sept. data"); foreach (Post item in septData) { Console.WriteLine(item); } }
public IList <T> GetList <T>(Dictionary <string, object> parameters = null) where T : class { return(_dataAccessor.GetAll <T>(parameters)?.ToList()); }