ObjectSet<T> and List<T>

Mar 20, 2010 at 7:20 AM
Edited Mar 20, 2010 at 7:31 AM


Sorry, I had an error that I can't convert ObjectSet to List. I overlooked that I use the class List and not the IList interface.

But I have another question.


Like I have to implement an interface of one-to-many relationship:



class Campus: ICampus {

// from ICampus
public IList<IBuilding> Buildings {
get {
return (IList<IBuilding>)buildingsHolder.InnerObject;

[Relation("ID = CampusID")]
private ObjectSetHolder<Building> buildingsHolder;

The ICampus and IBuilding don't have any [Persistent("Table")] attributes or any other Opf3 attributes.

The ICampus and IBuilding don't have any [Persistent] or any other Opf3 attributes. They are just the model interfaces. Will the code above work, i.e. will Opf3 load the classes correctly?

Mar 21, 2010 at 6:44 PM
Edited Mar 21, 2010 at 6:45 PM

Hi devent,

to make this code work you have to register the interface with the class. In this case the ICampus with the Campus class. The Campus class needs to have the persistent attribute, whereas the ICampus doesn't need to have it.

The method for registration is found in the Chili.Opf3.Mapping.TypeMapping class and is called RegisterPersistentInterface:

TypeMapping.RegisterPersistentInterface(typeof(ICampus), typeof(Campus));