public void Remove(int consumerDirectoryId)
 {
     using (var conn = Database.Open())
     {
         conn.Execute(RelationshipSql.Remove(consumerDirectoryId));
     }
 }
        public void Add(IList <Model.Relationship> list)
        {
            if (list == null || list.Count == 0)
            {
                return;
            }
            using (var conn = Database.Open())
            {
                var trans = conn.BeginTransaction();
                try
                {
                    string sql = RelationshipSql.Remove(list[0].ConsumerInfo.ConsumerDirectoryId);

                    conn.Execute(sql, trans);

                    foreach (var item in list)
                    {
                        var tuple = RelationshipSql.Add(item);
                        conn.Execute(tuple.Item1, (object)tuple.Item2, trans);
                    }

                    trans.Commit();
                }
                catch
                {
                    trans.Rollback();
                }
            }
        }
 public void RemoveAll()
 {
     using (var conn = Database.Open())
     {
         conn.Execute(RelationshipSql.RemoveAll());
     }
 }
 public IEnumerable <Model.Relationship> Select(int consumerDirectoryId)
 {
     using (var conn = Database.Open())
     {
         string sql = RelationshipSql.SelectBy(consumerDirectoryId);
         return(conn.Query <Model.Relationship, Model.ConsumerInfo, Model.ProviderInfo, Model.Relationship>(sql, SelectConvert, splitOn: "split"));
     }
 }
 public void Add(Model.Relationship relationship)
 {
     using (var conn = Database.Open())
     {
         var tuple = RelationshipSql.Add(relationship);
         conn.ExecuteScalar <int>(tuple.Item1, (object)tuple.Item2);
     }
 }
        public bool RelationIsExists(int providerDirectoryId, int consumerDirectoryId)
        {
            using (var conn = Database.Open())
            {
                var tuple = RelationshipSql.IsExists(consumerDirectoryId, providerDirectoryId);
                var model = conn.Query <Model.Relationship>(tuple.Item1, (object)tuple.Item2);

                if (model.Any())
                {
                    return(false);
                }
                return(true);
            }
        }
 public IEnumerable <Model.Relationship> SelectAll()
 {
     using (var conn = Database.Open())
     {
         return(conn.Query <Model.Relationship, Model.ConsumerInfo, Model.ProviderInfo, Model.Relationship>(RelationshipSql.FindAll(), SelectConvert, splitOn: "split").ToList());
     }
 }