Exemplo n.º 1
0
 /// <summary>
 /// Loads the entity or set of entities from the thunk represented by the thunk's entity id(s).
 /// </summary>
 /// <returns></returns>
 public object Load()
 {
     if (id != null)
     {
         return(context.GetList <R>().GetEntityById(id.Value));
     }
     else
     {
         return(context.GetList <R>().GetEntitiesById(ids));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an entity reference for deferred loading.
        /// </summary>
        /// <param name="context">Context used to load the entity.</param>
        /// <param name="id">Primary key of the entity to be loaded.</param>
        internal EntityRef(SharePointDataContext context, int id)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            _list   = context.GetList <T>();
            _id     = id;
            _entity = default(T);
            _loaded = false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a set of entity references for lazy loading.
        /// </summary>
        /// <param name="context">Context used to load the entities.</param>
        /// <param name="ids">Primary keys of the entities to be loaded.</param>
        /// <param name="onAdd">Action to take when an entity is added to the set.</param>
        /// <param name="onRemove">Action to take when an entity is removed from the set.</param>
        internal EntitySet(SharePointDataContext context, int[] ids, Action <T> onAdd, Action <T> onRemove)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (ids == null)
            {
                throw new ArgumentNullException("ids");
            }

            _list     = context.GetList <T>();
            _ids      = ids;
            _entities = null;
            _loaded   = false;
            _onAdd    = onAdd;
            _onRemove = onRemove;
        }