Ejemplo n.º 1
0
        public void TestOneToMany()
        {
            PhoneEntity[] mPhones = new PhoneEntity[5];
            PhoneEntity[] tPhones = new PhoneEntity[5];
            for (int index = 0; index < 5; index++)
            {
                mPhones[index] = new PhoneEntity('M', "158-" + index);
                tPhones[index] = new PhoneEntity('T', "020-" + index);
            }
            PhoneDao phoneDao = new PhoneDao();

            phoneDao.save(mPhones);
            phoneDao.save(tPhones);

            CatEntity           cat    = new CatEntity("lisi", 'F', 100.0f);
            IList <PhoneEntity> phones = new List <PhoneEntity>();

            phones.Add(mPhones[0]);
            phones.Add(tPhones[0]);
            cat.Phones = phones;
            CatDao catDao = new CatDao();

            catDao.save(cat);

            CatEntity getCat = catDao.getByName("lisi");
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            CatDao dao   = new CatDao();
            var    model = dao.GetList().ToList();

            return(View(model));
        }
Ejemplo n.º 3
0
        protected void buttonAddCat_Click(object sender, EventArgs e)
        {
            CatDao    dao = new CatDao();
            CatEntity cat = new CatEntity("cat1", 'F', 10.0f);

            dao.save(cat);
        }
Ejemplo n.º 4
0
        public void TestBatchSaveCatDepartment()
        {
            DepartmentDao    dao        = new DepartmentDao();
            DepartmentEntity department = dao.getByName("2");

            CatEntity[] cats = createCatsWithoutDepartment();
            foreach (var cat in cats)
            {
                cat.Department = department;
            }
            CatDao catDao = new CatDao();

            catDao.save(cats);
        }
Ejemplo n.º 5
0
        public void setViewBag(int?catid = null)
        {
            CatDao dao = new CatDao();

            ViewBag.CatID = new SelectList(dao.GetList(), "CatID", "CatName", catid);
        }