Example #1
0
        public U?GetId(string name)
        {
            if (name == null)
            {
                return(null);
            }

            if (!NameMap.ContainsKey(name))
            {
                using (Models.BodyDbContext ctx = new Models.BodyDbContext())
                {
                    T map = ctx.Set <T>().FirstOrDefault(v => v.Name == name);

                    if (map == null)
                    {
                        map = new T {
                            Name = name
                        };
                        ctx.Set <T>().Add(map);
                        ctx.SaveChanges();
                    }

                    IdMap[map.Id]     = map;
                    NameMap[map.Name] = map;
                }
            }

            return(NameMap[name].Id);
        }
Example #2
0
 /// <summary>
 /// Returns the index of the given column name.
 /// </summary>
 /// <param name="name">The name of the column to find.</param>
 /// <returns>The numeric index of column.</returns>
 public int IndexOf(string name)
 {
     if (!NameMap.ContainsKey(name))
     {
         throw new MySqlException("Column not found '" + name + "'");
     }
     return(NameMap[name]);
 }
Example #3
0
 public nameconfig GetNameConfig(short uiKey)
 {
     if (NameMap.ContainsKey(uiKey))     //检查是否有该键值
     {
         return(NameMap[uiKey]);
     }
     return(null);
 }
        /// <summary>
        /// Gets the value for the argument
        /// </summary>
        /// <param name="parameter">Parameter whose value to get</param>
        /// <returns>Value of the argument</returns>
        public string[] GetValue(CommandParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentException(nameof(parameter));
            }

            // Check in arguments parsed
            var longName = parameter?.GetFullLongName();
            var value    = ArgsParsed.ContainsKey(longName) ? ArgsParsed[longName] : null;

            // Check in short names
            if (value == null)
            {
                var shortName = NameMap.ContainsKey(longName) ? NameMap[longName] : null;
                if (shortName != null)
                {
                    value = ArgsParsed.ContainsKey(shortName) ? ArgsParsed[shortName] : null;
                }
            }

            return(value);
        }