public void InsertBaseUser() { var user = new SuperUser(); var user2 = new SuperUser2(); Database.Insert<BaseUser>(user); Database.Insert<BaseUser>(user2); Database.Mappers.RegisterFactory<BaseUser>(x => { return x["Name"].ToString() == "Super" ? (BaseUser)new SuperUser() : new SuperUser2(); }); var baseUser = Database.Fetch<BaseUser>("where name = @0", "Super").First(); var baseUser2 = Database.Fetch<BaseUser>("where name = @0", "Super2").First(); Assert.AreEqual(baseUser.GetType(), typeof(SuperUser)); Assert.AreEqual(baseUser2.GetType(), typeof(SuperUser2)); Assert.AreEqual(baseUser.Name, "Super"); Assert.AreEqual(baseUser2.Name, "Super2"); Database.Mappers.ClearFactories(); }
public void InsertBaseUser() { var user = new SuperUser(); var user2 = new SuperUser2(); Database.Insert <BaseUser>(user); Database.Insert <BaseUser>(user2); Database.Mappers.RegisterFactory <BaseUser>(x => { return(x["Name"].ToString() == "Super" ? (BaseUser) new SuperUser() : new SuperUser2()); }); var baseUser = Database.Fetch <BaseUser>("where name = @0", "Super").First(); var baseUser2 = Database.Fetch <BaseUser>("where name = @0", "Super2").First(); Assert.AreEqual(baseUser.GetType(), typeof(SuperUser)); Assert.AreEqual(baseUser2.GetType(), typeof(SuperUser2)); Assert.AreEqual(baseUser.Name, "Super"); Assert.AreEqual(baseUser2.Name, "Super2"); Database.Mappers.ClearFactories(); }