One instance per database record


It would be very useful if, within an object context, the same database record was represented by one object. In other words, different variables would contain the same object reference even if loaded through different GetObject (or GetObjectSet, etc.) calls.
dim obj1 as T = context.GetObject(of T)("ID={0}",1)
dim obj2 as T = context.GetObject(of T)("ID={0}",1)
dim objList as ObjectSet(0f T) = GetObjectSet(of T)
dim obj3 as T = Aggregate v in objList Where v.ID = 1 Into First()
Object.ReferenceEquals(obj1,obj2) should return true
Object.ReferenceEquals(obj2,obj3) should return true
Object.ReferenceEquals(obj3,obj1) should return true
Replacing "result.Add(obj);" (Change set: 44628, SimpleCacheManager.cs, Line 234) with "result.Add((T)persistent.Persistent);" seems to produce the desired behavior.
Closed Dec 11, 2009 at 3:42 AM by littleguru
Seems to be closed.


littleguru wrote Dec 11, 2009 at 3:41 AM

David, is this to close?

wrote Dec 11, 2009 at 3:42 AM

talib_klewki wrote Feb 18, 2010 at 7:21 PM

I think there is still problem with nested objects.
For the class ParentRow that contains:
ObjectSet<ChildRow> Children { ... }

and class ChildRow with:
ParentRow Parent { ...}

ParentRow.Children[0].Parent returns different object than ParentRow.

wrote Feb 13, 2013 at 10:28 PM

wrote May 16, 2013 at 4:07 AM