Ejemplo n.º 1
0
        public ObjectTrackingInfo GetObjectTrackingInfo(object obj)
        {
            ObjectTrackingInfo info;

            ObjectsTracking.TryGetValue(obj, out info);
            return(info);
        }
Ejemplo n.º 2
0
        public bool TryAttachObject(object obj)
        {
            if (ObjectsTracking.ContainsKey(obj))
            {
                return(false);
            }

            AttachObject(obj);
            return(true);
        }
Ejemplo n.º 3
0
        public ObjectTrackingInfo AttachObject(object objectToTrack)
        {
            //implement same as above but kindly throw exceptions instead

            if (ObjectsTracking.ContainsKey(objectToTrack))
            {
                throw new Exception("Object is already being tracked");
            }

            return(GetTrackingInfo(objectToTrack));
        }
Ejemplo n.º 4
0
        public ObjectTrackingInfo GetTrackingInfo(object obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            ObjectTrackingInfo objTrkInfo;

            if (!ObjectsTracking.TryGetValue(obj, out objTrkInfo))
            {
                var entityMap = Context.ContextMap.EntityMaps.SingleOrDefault(q => q.EntityType == obj.GetType() || q.EntityType == obj.GetType().BaseType);
                if (entityMap == null)
                {
                    throw new Exception("Entity does not have an associated map.");
                }

                objTrkInfo = new ObjectTrackingInfo(obj, entityMap.GetDbSet(Context), false);
                //entityMap.RelationshipMaps.Select(
                ObjectsTracking.Add(obj, objTrkInfo);
            }

            return(objTrkInfo);
        }
Ejemplo n.º 5
0
        public void DetachObject(object objectToDetach)
        {
            ObjectsTracking.Remove(objectToDetach);

            //traverse relationships and perform this recursively
        }