List<ForeignKey> LoadForeignKeys(string tblName)
        {
            using (var cmd=this._factory.CreateCommand())
            {
                cmd.Connection=this._connection;
                cmd.CommandText=String.Format(FKEY_INFO_SQL,tblName);

                var result=new List<ForeignKey>();
                using (IDataReader rdr=cmd.ExecuteReader())
                {
                    while(rdr.Read())
                    {
                        ForeignKey key=new ForeignKey();
                        key.PrimaryTable=rdr["table"].ToString();
                        key.PrimaryColumns=new [] { rdr["to"].ToString() };
                        key.ForeignColumns=new [] { rdr["from"].ToString() };
                        result.Add(key);
                    }
                }
                return result;
            }
        }
예제 #2
0
 public string GetUpdateDeleteRule(ForeignKey fk)
 {
     var sb = new System.Text.StringBuilder();
     if (fk.UpdateRule!=System.Data.Rule.None)
         sb.AppendFormat(".OnUpdate(System.Data.Rule.{0})", fk.UpdateRule);
     if (fk.DeleteRule != System.Data.Rule.None)
         sb.AppendFormat(".OnDelete(System.Data.Rule.{0})", fk.DeleteRule);            
     return sb.ToString();
 }