public void FastExpandoCanExpandByObject()
        {
            FastExpando o = FastExpando.FromObject(new { Id = 1, Text = "foo" });

            o.Expand(new { Id = 2, Guest = "boo" });
            dynamic d = o;

            Assert.AreEqual(6, o.Count());
            Assert.AreEqual(2, d["ID"]);
            Assert.AreEqual("foo", d["Text"]);
            Assert.AreEqual("boo", d["GUEST"]);
        }
示例#2
0
        static void Expando_Expand()
        {
            Beer beer = new Beer()
            {
                Name = "Sly Fox IPA"
            };
            Glass glass = new Glass()
            {
                Ounces = 32
            };

            // create an expando and combine the objects
            FastExpando x = beer.Expand();

            x.Expand(glass);

            // look! a dynamic object
            dynamic d = x;

            Console.WriteLine("{0}", d.Name);
            Console.WriteLine("{0}", d.Ounces);
        }
        public void TestConvenienceExpandoQueriesWithDynamicObject()
        {
            // start with a dynamic object
            dynamic o = new FastExpando();

            o["ID"]   = 1;
            o["Text"] = "foo";

            // expand the dynamic
            var p = new { Id = 2, Guest = "boo" };

            var         list = Connection().QuerySql("SELECT ID=CONVERT (int, @ID), Text=@Text, Guest=@Guest", (object)o.Expand(p));
            FastExpando f    = list[0];
            dynamic     d    = f;

            Assert.AreEqual(3, f.Count());
            Assert.AreEqual(2, d["ID"]);
            Assert.AreEqual("foo", d["Text"]);
            Assert.AreEqual("boo", d["GUEST"]);
        }
		public void TestConvenienceExpandoQueriesWithDynamicObject()
		{
			// start with a dynamic object
			dynamic o = new FastExpando();
			o.Id = 1;
			o.Text = "foo";

			// expand the dynamic
			var p = new { Id = 2, Guest = "boo" };

			var list = _connection.QuerySql("SELECT ID=CONVERT (int, @ID), Text=@Text, Guest=@Guest", (object)o.Expand(p));
			FastExpando f = list[0];
			dynamic d = f;

			Assert.AreEqual(3, f.Count());
			Assert.AreEqual(2, d.ID);
			Assert.AreEqual("foo", d.Text);
			Assert.AreEqual("boo", d.GUEST);
		}