New Posts New Posts RSS Feed: Add new objects to a ReadOnlyEntityList ...
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Add new objects to a ReadOnlyEntityList ...

 Post Reply Post Reply
Author
msosa View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Feb-2009
Posts: 6
Post Options Post Options   Quote msosa Quote  Post ReplyReply Direct Link To This Post Topic: Add new objects to a ReadOnlyEntityList ...
    Posted: 04-Feb-2009 at 7:21am

Hi, I'm evaluating the product and so far it very good. The issue I'm dealing with is as folows: I have an User object that has an Roles property, witch is a relation with Rol object; so, an give user can have several roles. I want the administrator to be able to select those roles form a checkedlistbox. What I need to know is how to add those selected roles to the Roles property (a ReadOnlyEntityList) of the User object.

 
Thanks,
Maximiliano.


Edited by msosa - 04-Feb-2009 at 7:21am
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 04-Feb-2009 at 8:31pm
You can't modify a ReadOnlyEntityList (that's why it is a "ReadOnlyEntityList"), but usually you  can create a new ReadOnlyEntityList.  For example, here is how I might modify the Cache strategy for Orders, a ReadOnlyEntityList<Order>

public override ReadOnlyEntityList<Order> Orders {

get {

return new ReadOnlyEntityList<Order>(this.PersistenceManager.GetChildren<Order>(this, EntityRelations.Employee_Order, QueryStrategy.DataSourceThenCache, true));

}

}

Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 06-Feb-2009 at 11:08am
Maximiliano,
 
In DevForce Classic, you can't directly add or remove items from the list returned by a navigation property.  Fortunately, this ReadOnlyEntityList is actually a "live" list and will effectively monitor actions on the PersistenceManager for items to be added or removed.  In your case, you should see new items in the User.Roles list when you create a new "UserRole" entity (and add it to the PM).  I'm assuming that you have some sort of "UserRole" linking entity which contains foreign keys to the "User" and "Role" objects - so to add a specific role to a user you create a new "UserRole" object for that user.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down