Example #1
0
        void multiple_belongs_to_columns_referencing_the_same_table()
        {
            before = () =>
            {
                familys = new Familys();

                followings = new Followings();

                seed.PurgeDb();

                seed.CreateTable("Familys", new dynamic[]
                {
                    seed.Id(),
                    new { Name = "nvarchar(255)" }
                }).ExecuteNonQuery();

                seed.CreateTable("Followings", new dynamic[]
                {
                    seed.Id(),
                    new { FamilyId = "int" },
                    new { FollowingId = "int" }
                }).ExecuteNonQuery();

                var userId = new { Name = "jane" }.InsertInto("Familys");

                var userId2 = new { Name = "john" }.InsertInto("Familys");

                new { FamilyId = userId, FollowingId = userId2 }.InsertInto("Followings");
            };

            it["both belongs to references are accessible"] = () =>
            {
                var firstFollowing = followings.All().First();

                (firstFollowing.Family().Name as string).should_be("jane");

                (firstFollowing.Following().Name as string).should_be("john");
            };
        }
Example #2
0
        void multiple_belongs_to_columns_referencing_the_same_table()
        {
            before = () =>
            {
                familys = new Familys();

                followings = new Followings();

                seed.PurgeDb();

                seed.CreateTable("Familys", new dynamic[]
                {
                    seed.Id(),
                    new { Name = "nvarchar(255)" }
                }).ExecuteNonQuery();

                seed.CreateTable("Followings", new dynamic[]
                {
                    seed.Id(),
                    new { FamilyId = "int" },
                    new { FollowingId = "int" }
                }).ExecuteNonQuery();

                var userId = new { Name = "jane" }.InsertInto("Familys");

                var userId2 = new { Name = "john" }.InsertInto("Familys");

                new { FamilyId = userId, FollowingId = userId2 }.InsertInto("Followings");
            };

            it["both belongs to references are accessible"] = () =>
            {
                var firstFollowing = followings.All().First();

                (firstFollowing.Family().Name as string).should_be("jane");

                (firstFollowing.Following().Name as string).should_be("john");
            };
        }
Example #3
0
 public void RemoveFamily(Family item)
 {
     Familys.Remove(item);
 }
Example #4
0
 public void AddFamily(Family item)
 {
     Familys.Add(item);
 }