예제 #1
0
        public void TestInsertDataInDB()
        {
            try
            {
                using (var context = new DBContext())
                {
                    Type table1 = ManageAssembly.GetType("table1");

                    var data = context.InvokeMethod_Set(table1);

                    // New instance of table1
                    dynamic instance = Activator.CreateInstance(table1);

                    // add title property
                    instance.Title = "Test1";

                    // add new
                    data.Add(instance);

                    // save to DB
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
예제 #2
0
        public void TestGetDataFromDB()
        {
            try
            {
                using (var context = new DBContext())
                {
                    Type table1 = ManageAssembly.GetType("table1");

                    #region Invoke "Set" from context and then Invoke "FirstOrDefault"
                    // Get DBSet
                    dynamic data_Queryable = context.InvokeMethod_Set(table1);

                    dynamic data = context.Invoke_Generic("FirstOrDefault", table1, data_Queryable);
                    #endregion

                    Assert.AreEqual("Test1", data.Title);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }