Exemplo n.º 1
0
        public override ContextMenu GetContextMenu()
        {
            ContextMenu menu = new ContextMenu();

            TableMappingType tmt = ((TableNode)this.Parent).Table.MappingType;

            if (tmt != TableMappingType.MappedAsClass && tmt != TableMappingType.MappedAsIntermediateClass)
            {
                return(menu);
            }

            if (Column.IsPrimary)
            {
                menu.MenuItems.Add(new MenuItem("Don't map as primary key", new EventHandler(this.ChangePrimary)));
            }
            if (Column.IsMapped)
            {
                menu.MenuItems.Add(new MenuItem("Don't map as field", new EventHandler(this.ChangeMapping)));
            }

            if (!Column.IsMapped)
            {
                menu.MenuItems.Add(new MenuItem("Map column as field", new EventHandler(this.ChangeMapping)));
            }
            if (!MyTableNode.HasPrimary)
            {
                menu.MenuItems.Add(new MenuItem("Map as primary key", new EventHandler(this.ChangePrimary)));
            }
            if (!Column.IsMapped && !Column.IsPrimary)
            {
                menu.MenuItems.Add(new MenuItem("Map as foreign key...", new EventHandler(this.MakeForeignKey)));
            }

            return(menu);
        }
Exemplo n.º 2
0
 public virtual void FromXml(XmlElement element)
 {
     this.className   = element.Attributes["ClassName"].Value;
     this.mappingType = (TableMappingType)Enum.Parse(typeof(TableMappingType), element.Attributes["MappingType"].Value);
     this.name        = element.Attributes["Name"].Value;
     this.nameSpace   = element.Attributes["NameSpace"].Value;
     this.ndoOidType  = element.Attributes["NdoOidType"].Value;
     this.primaryKey  = element.Attributes["PrimaryKey"].Value;
 }
Exemplo n.º 3
0
        public Table(string name, string primaryKey, string summary)
        {
            //Regex regex = new Regex("^[A-Za-z_][A-Za-z_0-9]*$");
            //Match match = regex.Match(name);
            string tableName = name;
            string className = name;

            this.summary = summary;
            //if (!match.Success)
            //{

            //    tableName = "[" + name + "]";
            //    regex = new Regex("[A-Za-z_0-9]");
            //    className = string.Empty;
            //    for(int i = 0; i < name.Length; i++)
            //    {
            //        if (regex.Match(name.Substring(i, 1)).Success)
            //            className += name.Substring(i, 1);
            //    }
            //}

            if (name.Length > 1)
            {
                bool hasLower = false;
                for (int i = 0; i < name.Length; i++)
                {
                    if (char.IsLower(className[i]))
                    {
                        hasLower = true;
                        break;
                    }
                }
                if (!hasLower)
                {
                    className = className.Substring(0, 1) + className.Substring(1).ToLower();
                }
            }
            if (char.IsLower(className[0]))
            {
                if (name.Length > 1)
                {
                    className = className.Substring(0, 1).ToUpper() + className.Substring(1);
                }
                else
                {
                    className = name.ToUpper();
                }
            }

            this.name        = tableName;
            this.className   = className;
            this.primaryKey  = primaryKey;
            this.mappingType = TableMappingType.NotMapped;
        }