示例#1
0
        /// <summary>
        /// Persist the entity to the storage
        /// </summary>
        public bool Persist(PenneoConnector con)
        {
            con.Log((IsNew ? "Creating" : "Updating") + " " + GetType().Name + " (" + (Id.HasValue ? Id.ToString() : "new") + ")", LogSeverity.Information);
            var success = con.ApiConnector.WriteObject(this);

            if (!success)
            {
                con.Log((IsNew ? "Creating" : "Updating") + " " + GetType().Name + " (" + (Id.HasValue ? Id.ToString() : "new") + ") failed", LogSeverity.Information);
            }
            return(success);
        }
示例#2
0
 /// <summary>
 /// Unlink this entity with the given child in the storage
 /// </summary>
 protected bool UnlinkEntity(PenneoConnector con, Entity child)
 {
     con.Log("Unlinking " +
             GetType().Name + " (" + (Id.HasValue ? Id.ToString() : "new") + ") TO " +
             child.GetType().Name + " (" + (child.Id.HasValue ? Id.ToString() : "new") + ")", LogSeverity.Information);
     return(con.ApiConnector.UnlinkEntity(this, child));
 }
示例#3
0
 /// <summary>
 /// Delete the entity from the storage
 /// </summary>
 public void Delete(PenneoConnector con)
 {
     con.Log("Deleting " + GetType().Name + " (" + (Id.HasValue ? Id.ToString() : "new") + ")", LogSeverity.Information);
     if (!con.ApiConnector.DeleteObject(this))
     {
         throw new Exception("Penneo: Could not delete the " + GetType().Name);
     }
     Id = null;
 }
示例#4
0
        public QuerySingleObjectResult <T> FindOneBy <T>(QueryInput input)
            where T : Entity
        {
            _con.Log("FindOneBy (" + typeof(T).Name + ")", LogSeverity.Information);
            var result = new QuerySingleObjectResult <T>(FindBy <T>(input));

            return(result);
        }