Newer build of ObjectSpaces in VS.NET 2005

In contrast to what Dinesh Kulkarni, Program Manager said at the MSDN webcast, Visual Studio .NET 2005 does contain a newer build of ObjectSpaces. And that build contains many new features.

Here are some highlights of what I saw in the half hour that I had time to look into it:

  • Support for Generics: now you'll be able to get all the Generic goodness combined with OS. For example, the ObjectReader and ObjectSet will return your flavor of objects as strong typed references instead of System.Object references. No longer will you need to call:

    ObjectReader reader = os.GetObjectReader(typeof(Customer), ““, ““);

    This will now become:

    ObjectReader<Customer> reader = os.GetObjectReader<Customer>(““, ““);

    Every object returned from the reader will be of type Customer. Life is good!
  • Introduction of a PagedObjectReader.
  • New functionality in ObjectSpace class, such as persisting and resync some or all of the objects
  • The ObjectManager replaces the ObjectContext and also takes some of the functionality previously found in the ObjectSet en ObjectSpace classes. You can now accept or reject persisted changes, end the tracking of objects.
  • CompiledQuery now can be used in combination with an OPathParameterTable of OPathParameterCollection
  • New or expanded enumerations such as RetrieveOption (DefaultSpan, ImmediateLoad and LoadOnDemand) and Depth (CompositionTree, NoTraversal, ObjectGraph).
  • When starting tracking, objects can be marked with the ObjectState instead of the InitialState. This means that you could mark it as modified or deleted, but I haven't figured out what legal values are. Same goes for an extra parameter that you can specify called “path“

There's much more to discover, but I suggest you go right ahead and download the VS.NET 2005 Community Technology Preview of March now. Installation went pretty fast by the way. And don't get your hopes up on the documentation. There's even less than in the PDC bits. Lots of puzzling to do!

To be continued.

Comments

# Matt said:

The eventual production version mapper utility is also included (Thanks to Scott for showing me how):1) Start a web project2) Add a file of type &quot;Mapping File&quot;3) Viola - there's the mapper (in its infancy)

dinsdag 30 maart 2004 16:59
# Alex Thissen said:

Hi Matt,Thanks for pointing it out to me. It might have taken some time before I would have stumbled across it.You can also add a new xml file to your (non-website) project and give it the following content:&lt;msd:MappingSchemaxmlns:msd="http://schema.microsoft.com/mapping/2003/06/msd">&lt;/msd:MappingSchema>Then close and save it, rename it to a file with the .msd extension and open it again by double-clicking. Worked for me.

woensdag 31 maart 2004 8:18
# Scott said:

Just a couple of other useful tidbits for anyone testing this technology:1. There are some definite databinding issues. ObjectReader can be bound to both DropDown and GridView, ObjectSet cannot be bound to either.2. It appears that I can only use an instance of an ObjectReader one time. For example if retrieve a Reader and then use foreach to iterate through the collection it works fine. If I then databind to a DropDownList it doesn't populate. Incidently it works in reverse too. A retrieved Reader can be bound to a DropDownList and it populates fine, but then when walking through the collection with foreach each property is empty. I'm not sure how to explain this one.

woensdag 31 maart 2004 21:05
# Alex Thissen said:

Hi Scott, Nice to meet you here as well.The first problem also happened in the PDC bits. You could not bind to a ObjectSet directly. The workaround was to use another collection object, such as the ArrayList, and bind that instead. You used this code to get it: ArrayList arr = new ArrayList(myObjectSet); Pretty simple.However, this has been fixed. You can now bind an ObjectSet to a Listbox for example. Just remember that you need to have real properties for this, not just public fields. I must admit I haven't tried to get an ObjectSet to bind to a grid (Windows or Web) yet.The second problem you're having with the reader is to be expected. The ObjectReader objects behave pretty much the same as the DataReaders from ADO.NET. You can only use them once, like a cigarette or a match. In the PDC bits you would get an ObjectException when you tried to use it for the second time, e.g. in a foreach construct. In the March preview it silently skips the foreach loop. If you're iterating and databinding (i.e. using the reader multiple times), you will need to use an ObjectSet.Alex

woensdag 31 maart 2004 23:51
# Scott said:

Thanks for the reply Alex, that definitely explains my ObjectReader issue. Today, if I get a chance, I will verify that all the data I'm using is correct. Thanks again.

donderdag 1 april 2004 16:04