title: Assigning data to properties using a large switch statement... is there a more dynamic way to do this?
body: <p>So I'm pulling some information out of a database and I need to map it to my model's properties. My first attempt at this yielded a large switch statement which is following an obvious pattern. I am wondering if this fragile code can be expressed in a more dynamic fashion.</p>
  
  <pre><code>foreach (AttributeValue attributeValue in attributeValues)
  {
      string label = attributes.First(a =&gt; a.ID == attributeValue.AttributeID).Name;
      switch (attributeValue.AttributeName)
      {
          case "TaskSequence":
              TaskSequenceLabel = label;
              break;
          case "TaskStatus":
              TaskStatusLabel = label;
              break;
          case "InstallChangeNumber":
              InstallChangeNumberLabel = label;
              break;
          case "InstallChangeStart":
              InstallChangeStartLabel = label;
              break;
          case "InstallChangeEnd":
              InstallChangeEndLabel = label;
              break;
          case "SubmittedDateTime":
              SubmittedDateTimeLabel = label;
              break;
          case "InstalledDateTime":
              InstalledDateTimeLabel = label;
              break;
      }
  }
  </code></pre>
  
  <p>Basically what I am thinking is "Map labels to properties which have the label's value + "Label""</p>