public void SetParametersFromAnonymousObject() { var collection = new CqlParameterCollection { {"test.id", CqlType.Int}, {"test.value", CqlType.Text}, {"test.value2", CqlType.Blob}, {"test.map", CqlType.CreateType(CqlTypeCode.Map, CqlType.Text, CqlType.Boolean)} }; collection.Fixate(); var a = new {Id = 1, value2 = new byte[] {1, 2}, Value = "Hello!"}; collection.Set(a); Assert.AreEqual(a.Id, collection["test.id"].Value); Assert.AreEqual(a.Value, collection["test.value"].Value); Assert.AreEqual(a.value2, collection["test.value2"].Value); Assert.IsNull(collection[3].Value); }
public void SetParametersFromTwoObjects() { var collection = new CqlParameterCollection(); collection.Add("test.id", CqlType.Int); collection.Add("test.value", CqlType.Text); collection.Add("test.ignored", CqlType.Blob); collection.Add("test2.id", CqlType.Int); collection.Add("test2.value", CqlType.Text); collection.Add("test2.value2", CqlType.Blob); collection.Fixate(); var a = new A {Id = 1, Ignored = new byte[] {1, 2}, Value = "Hello!"}; var b = new B {Id = 2, Value2 = new byte[] {3, 4}, Value = "World!"}; collection.Set(a); collection.Set(b); Assert.AreEqual(a.Id, collection["test.id"].Value); Assert.AreEqual(a.Value, collection["test.value"].Value); Assert.IsNull(collection["test.ignored"].Value); Assert.AreEqual(b.Id, collection["test2.id"].Value); Assert.AreEqual(b.Value, collection["test2.value"].Value); Assert.AreEqual(b.Value2, collection["test2.value2"].Value); }