Book a Demo

Author Topic: HowTo Add TaggedValueType by AddIn  (Read 3817 times)

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
HowTo Add TaggedValueType by AddIn
« on: October 25, 2010, 09:02:35 pm »
Hello,

what would be the appropriate way to add a TaggedValueType through a AddIn?

Thanks for hints and links.

Regards
Rainer

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
Re: HowTo Add TaggedValueType by AddIn
« Reply #1 on: October 26, 2010, 01:53:05 am »
Hello,

ok, I found the answer  :)

private void AddPropertyTypeIfNotExisting(Repository repository, string property, string description, string notes)
        {
            if(this.PropertyExists(property, repository)) return;

            string sql = string.Empty;
            sql = "INSERT INTO t_propertytypes (Property, Description, Notes) VALUES (";
            sql = sql + "'" + property + "', ";
            sql = sql + "'" + description + "', ";
            sql = sql + "'" + notes + "')";
            repository.Execute(sql);
        }

Regards
Rainer

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: HowTo Add TaggedValueType by AddIn
« Reply #2 on: October 26, 2010, 09:47:25 am »
The appropriate way would be more like
Code: [Select]
EA.PropertyType tagType = rep.PropertyTypes.AddNew(property, "");
tagType.Description = description;
tagType.Detail = notes;
tagType.Update()

Your code will break if any of those strings contain '.
« Last Edit: October 26, 2010, 09:48:56 am by simonm »

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
Re: HowTo Add TaggedValueType by AddIn
« Reply #3 on: October 26, 2010, 05:24:00 pm »
Hello Simon,

thank you very much for your advise!
I will refactor my code right away, since the appropriate way looks much nicer.

Regards
Rainer