public void SetValueToDifferentType() { var obj = new BaObject(true, new { Str = "", Base = new MyBaseObject(), Derived = new MyDerivedObject() }); Assert.That.Throws <InvalidOperationException>(() => { obj["Str"] = 123; }); obj["Base"] = new MyDerivedObject(); Assert.That.Throws <InvalidOperationException>(() => { obj["Derived"] = new MyBaseObject(); }); }
public void Test1() { IDataStore s = XpoDefault.GetConnectionProvider(connection, AutoCreateOption.DatabaseAndSchema); var StoreType = s.GetType(); Debug.WriteLine(StoreType); //DevExpress.Xpo.DB.SQLiteConnectionProvider XPDictionary d = new ReflectionDictionary(); XpoDefault.Dictionary = d; XpoDefault.DataLayer = new SimpleDataLayer(d, new MyDataStore(s)); XPClassInfo order = CreateObject(s, "Order", typeof(MyBaseObject)); XPClassInfo customer = CreateObject(s, "Customer", typeof(MyBaseObject)); AssociationAttribute a = new AssociationAttribute("CustomerOrders"); //, typeof(DetailDataObject) a.ElementTypeName = "Order"; AssociationAttribute a1 = new AssociationAttribute("CustomerOrders"); //, typeof(ParentDataObject) order.CreateMember("Customer", customer, new Attribute[] { a1 }); customer.CreateMember("Orders", typeof(XPCollection), true, new Attribute[] { a }); customer.CreateMember("Name", typeof(string)); customer.CreateMember("DoB", typeof(DateTime)); Session session = new Session(XpoDefault.DataLayer); session.UpdateSchema(order, customer); UnitOfWork WorkingSession = new UnitOfWork(XpoDefault.DataLayer); MyBaseObject Joche = customer.CreateObject(WorkingSession) as MyBaseObject; Joche.SetMemberValue("Name", "Jose Manuel Ojeda Melgar"); Joche.SetMemberValue("DoB", DateTime.Now); WorkingSession.CommitChanges(); //Joche.SetMemberValue("Name", "Joche"); //WorkingSession.CommitChanges(); Dictionary <string, object> keyValuePairs = new Dictionary <string, object>(); keyValuePairs.Add("Name", "Joche"); keyValuePairs.Add("DoB", DateTime.Now); //CreateStatement(customer, Joche.GetMemberValue(customer.KeyProperty.Name), DateTime.Now, 1); CreateStatement(customer, Joche.GetMemberValue(customer.KeyProperty.Name), keyValuePairs); Assert.Pass(); }
public MyBaseObjectDebugView(MyBaseObject baseObject) { _baseObject = baseObject; }
public void Add(MyBaseObject obj) { /* cast to T and insert */ }