/// <summary>
        /// Persists a new instance of SavedQuery.
        /// </summary>
        /// <returns></returns>
        public void Save(SavedQuery savedQuery)
        {
            if (savedQuery == null)
            {
                return;
            }

            if (savedQuery.Id == Guid.Empty)
            {
                savedQuery.Id = Guid.NewGuid();

                if (savedQuery.CreatedBy == Guid.Empty)
                {
                    savedQuery.CreatedBy = savedQuery.LastModBy;
                }

                DBSavedQuery.Create(
                    savedQuery.Id,
                    savedQuery.Name,
                    savedQuery.Statement,
                    savedQuery.CreatedUtc,
                    savedQuery.CreatedBy);
            }
            else
            {
                DBSavedQuery.Update(
                    savedQuery.Id,
                    savedQuery.Statement,
                    savedQuery.LastModUtc,
                    savedQuery.LastModBy);
            }
        }
        private List <SavedQuery> LoadListFromReader(IDataReader reader)
        {
            List <SavedQuery> savedQueryList = new List <SavedQuery>();

            try
            {
                while (reader.Read())
                {
                    SavedQuery savedQuery = new SavedQuery();
                    savedQuery.Id         = new Guid(reader["Id"].ToString());
                    savedQuery.Name       = reader["Name"].ToString();
                    savedQuery.Statement  = reader["Statement"].ToString();
                    savedQuery.CreatedUtc = Convert.ToDateTime(reader["CreatedUtc"]);
                    savedQuery.CreatedBy  = new Guid(reader["CreatedBy"].ToString());
                    savedQuery.LastModUtc = Convert.ToDateTime(reader["LastModUtc"]);
                    savedQuery.LastModBy  = new Guid(reader["LastModBy"].ToString());
                    savedQueryList.Add(savedQuery);
                }
            }
            finally
            {
                reader.Close();
            }

            return(savedQueryList);
        }
        public SavedQuery Fetch(string name)
        {
            using (IDataReader reader = DBSavedQuery.GetOne(name))
            {
                if (reader.Read())
                {
                    SavedQuery savedQuery = new SavedQuery();
                    savedQuery.Id         = new Guid(reader["Id"].ToString());
                    savedQuery.Name       = reader["Name"].ToString();
                    savedQuery.Statement  = reader["Statement"].ToString();
                    savedQuery.CreatedUtc = Convert.ToDateTime(reader["CreatedUtc"]);
                    savedQuery.CreatedBy  = new Guid(reader["CreatedBy"].ToString());
                    savedQuery.LastModUtc = Convert.ToDateTime(reader["LastModUtc"]);
                    savedQuery.LastModBy  = new Guid(reader["LastModBy"].ToString());

                    return(savedQuery);
                }
            }

            return(null);
        }
Example #4
0
 /// <summary>
 /// Compares 2 instances of SavedQuery.
 /// </summary>
 public static int CompareByCreatedUtc(SavedQuery savedQuery1, SavedQuery savedQuery2)
 {
     return(savedQuery1.CreatedUtc.CompareTo(savedQuery2.CreatedUtc));
 }
Example #5
0
 /// <summary>
 /// Compares 2 instances of SavedQuery.
 /// </summary>
 public static int CompareByStatement(SavedQuery savedQuery1, SavedQuery savedQuery2)
 {
     return(savedQuery1.Statement.CompareTo(savedQuery2.Statement));
 }
Example #6
0
 /// <summary>
 /// Compares 2 instances of SavedQuery.
 /// </summary>
 public static int CompareByName(SavedQuery savedQuery1, SavedQuery savedQuery2)
 {
     return(savedQuery1.Name.CompareTo(savedQuery2.Name));
 }
Example #7
0
 /// <summary>
 /// Compares 2 instances of SavedQuery.
 /// </summary>
 public static int CompareByLastModUtc(SavedQuery savedQuery1, SavedQuery savedQuery2)
 {
     return(savedQuery1.LastModUtc.CompareTo(savedQuery2.LastModUtc));
 }