Пример #1
0
        public static void Main(string[] args)
        {
            // remote -> "den1.mssql7.gear.host", "DPTest", "dptest", "Me3JyhRLOg-_"

            // local
            // maciopelo -> "DESKTOP-HVUO0CP", "TestDB"
            // szymon -> "LAPTOP-BHF7G1P9", "RelationshipsTest" databases (like tests directories)
            // Blacki7 - > "DESKTOP-BO1NL9H", "test1"  (work in progress)

            DataManager mountainManager = new DataManager("LAPTOP-BHF7G1P9", "RelationshipsTest");
            //DataManager mountainManager = new DataManager("DESKTOP-HVUO0CP", "RelationshipsTest");

            Flea flea1 = new Flea("Jumper", 42.9);
            Flea flea2 = new Flea("Pavel", 12.19);
            Flea flea3 = new Flea("Pearly", 42.93);

            Bowl bowl = new Bowl("DogFood", 10);

            Dog testDog = new Dog("Barry", 6);
            Dog dog     = new Dog("Burek", 10);

            testDog.AddFlea(flea1);
            testDog.AddFlea(flea2);
            testDog.AddFlea(flea3);

            testDog.SetBowl(bowl);

            Label label1 = new Label(234);
            //Label label2 = new Label(235);
            Label label3 = new Label(236);

            Sheep sheep1 = new Sheep("Mary", 2.35);

            sheep1.SetLabel(label1);

            Sheep sheep2 = new Sheep("Pole", 1.84);
            //sheep2.SetLabel(label2);

            Sheep sheep3 = new Sheep("Ann", 1.27);

            sheep3.SetLabel(label3);

            Alp alp1 = new Alp("Not so Silicon Valley", 5.61);
            //Alp alp2 = new Alp("Mountain Secret", 7.42);

            Shepherd testShepherd = new Shepherd("Frank");

            testShepherd.SetDog(testDog);

            testShepherd.AddSheep(sheep1);
            testShepherd.AddSheep(sheep2);
            testShepherd.AddSheep(sheep3);

            testShepherd.AddAlp(alp1);
            //testShepherd.AddAlp(alp2);

            //create
            mountainManager.CreateTable(testShepherd);
            mountainManager.Insert(testShepherd);

            testShepherd.SetDog(dog);
            mountainManager.Insert(dog);

            mountainManager.Update(dog);

            //update
            testShepherd.name = "Johnny";
            sheep2.name       = "Madeleine";
            flea3.jumpLevel   = 35.15;
            mountainManager.Update(testShepherd);
            mountainManager.Update(sheep2);
            mountainManager.Update(flea3);

            //delete
            mountainManager.Delete(flea3);
            mountainManager.Delete(dog);

            //Test for relation-object mapping
            Shepherd newShepherd = (Shepherd)mountainManager.Select(typeof(Shepherd), 1);

            IntroduceShepherd(newShepherd);
            Console.WriteLine("Utter success");
        }
Пример #2
0
 public void AddAlp(Alp newAlp)
 {
     this.alps.Add(newAlp);
 }