New Posts New Posts RSS Feed: removing a dynamic type?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

removing a dynamic type?

 Post Reply Post Reply
Author
labcede View Drop Down
Newbie
Newbie


Joined: 25-Jul-2007
Posts: 8
Post Options Post Options   Quote labcede Quote  Post ReplyReply Direct Link To This Post Topic: removing a dynamic type?
    Posted: 16-Aug-2007 at 11:40am
Is it possible to remove a dynamic type from memory (so that i can redefine it)?

I have DataTable "X" w/ 3 columns used for the EntityTypeInfo for a dynamic type w/ the key equal to "DTR."  I modify table "X" and now it has 4 columns.  I'd like to redfine my Dynamic Type "DTR" so that the EntityTypeInfo reflects these changes.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 16-Aug-2007 at 12:19pm

This is just a guess...try removing it from the PersistenceManager (including query cache).  RemoveEntity, maybe?  This is a good question.

Btw, it sounds like you may be utilizing datagridviews to present your data...are you using a datagridviewbindingmanager to bind the dynamic entity to the grid?  If so, how are you doing it?
 
Thanks!
Bill
Back to Top
labcede View Drop Down
Newbie
Newbie


Joined: 25-Jul-2007
Posts: 8
Post Options Post Options   Quote labcede Quote  Post ReplyReply Direct Link To This Post Posted: 16-Aug-2007 at 12:39pm
RemoveEntity does not remove the type in memory.

Yes, I'm using the datagridviewbindingmanager ... I've done 2 separate test with both the Designer and at run-time without problems.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 16-Aug-2007 at 1:53pm

The key to manipulating the DGVBM in code is to add a ViewDescriptor (IdeaBlade) to the Descriptiors collection...not a DataGridViewBindingDescriptor (DotNetControl).  Hopefully, IdeaBlade will include an example of this in their next release of the tutorial solution.  I have an example if anyone is interested.

Is it possible to set the type to null?  I will try this and let you know if it works.
 
Bill
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 16-Aug-2007 at 1:56pm
Nope, null does not work.  The key still exists.  It must be in the PM somewhere.
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: 16-Aug-2007 at 4:01pm

The Type itself that you've created cannot be removed from memory (or really more correctly from the AppDomain), but you can, in some situations, modify the columns of the corresponding EntityTable.

If you didn't define a primary key when creating the type, the actual EntityTable managed by the PM will always be recreated based on the latest query for the dynamic type.
 
If you did define a primary key, you can possibly still modify the EntityTable without harm, but it does require some care.  How you do this modification may also depend on how you created the type, but here's one way:
 
// Get the table out of the PM
EntityTable tbl = mPm.GetTable(myDynamicEntityType);
// Modify the table
tbl.Columns.Add("NewIntCol", typeof(int));
//Optionally reset the prototype table
EntityTypeInfo.SetPrototypeTable(tbl, "");
You do this at your own risk, and it's doubtful that persistence operations on the type would work, but I haven't tried.  If you're using a BOS you might also run into trouble with the schemas being out of sync between the client and server, but again I have tried it out. 
Back to Top
labcede View Drop Down
Newbie
Newbie


Joined: 25-Jul-2007
Posts: 8
Post Options Post Options   Quote labcede Quote  Post ReplyReply Direct Link To This Post Posted: 17-Aug-2007 at 5:58am
great!  that worked.  i'm not really considered with keeping the schemas in sync with the persistence server.  my dynamic entity is only used locally and not for any data persistence.

thanks!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down