private bool TryGetCachedObject(object[] keyValues, out T cached) { cached = default(T); if (refersToPrimaryKey) { var type = member.IsAssociation ? member.Association.OtherType : member.DeclaringType; var cachedObject = services.GetCachedObject(type, keyValues); if (cachedObject != null) { cached = (T)cachedObject; return(true); } } return(false); }
private TrackedObject GetOtherItem(MetaAssociation assoc, object instance) { if (instance == null) { return(null); } object obj = null; if (assoc.ThisMember.StorageAccessor.HasAssignedValue(instance) || assoc.ThisMember.StorageAccessor.HasLoadedValue(instance)) { obj = assoc.ThisMember.MemberAccessor.GetBoxedValue(instance); } else if (assoc.OtherKeyIsPrimaryKey) { var foreignKeyValues = CommonDataServices.GetForeignKeyValues(assoc, instance); obj = services.GetCachedObject(assoc.OtherType, foreignKeyValues); } if (obj == null) { return(null); } return(tracker.GetTrackedObject(obj)); }