public void Remove(string id) { var comm1 = new NpgsqlCommand("delete from content where id=@id", _connection); comm1.Parameters.AddWithValue("@id", id); comm1.ExecuteNonQuery(); DBFactory.DeleteMemcachedData(id); //var comm2 = new NpgsqlCommand("delete from relationship where slave=@id", _connection); //comm2.Parameters.AddWithValue("@id", id); //comm2.ExecuteNonQuery(); RemoveRelationship(id); var list = DBFactory.GetMemcachedRelationship(id); if (list == null) { list = new List <string>(); var comm3 = new NpgsqlCommand("select slave from relationship where master=@id", _connection); comm3.Parameters.AddWithValue("@id", id); var reader = comm3.ExecuteReader(); while (reader.Read()) { list.Add(reader.GetString(0)); } reader.Close(); } foreach (var kidId in list) { Remove(kidId); } var comm4 = new NpgsqlCommand("delete from relationship where master=@id", _connection); comm4.Parameters.AddWithValue("@id", id); comm4.ExecuteNonQuery(); DBFactory.DeleteMemcachedRelationship(id); }
public XElement GetChildren(string parentId) { var kids = new XElement("Children"); var kidsList = DBFactory.GetMemcachedRelationship(parentId); if (kidsList != null && kidsList.Count > 0) { foreach (var directKid in kidsList) { kids.Add(Find(directKid)); } return(kids); } var directKids = GetKids(parentId); foreach (var directKid in directKids) { DBFactory.AddMemcachedRelationship(parentId, directKid); kids.Add(Find(directKid)); } return(kids); }