title: Lightswitch HTML - add foreign key based upon date field (C#)
body: <p><strong>What I Trying to achieve:</strong></p>
  
  <p>When a user enters a line into a table (EntryLine), they enter a description and a date. Now in C# under the inserting code of EntryLine, I can use this code:</p>
  
  <pre><code>    partial void EntryLine_Inserting(EntryLine entity)
      {
  
          if (entity.Day == null)
          {
              DateTime getDay = Convert.ToDateTime(entity.EntryDate);                
              entity.Day = getDay.ToString("dddd");
  
              //entity.Day = getDate
          }
  
      }
  </code></pre>
  
  <p>Now what this code does above is takes the date entered by the user and just adds the day into the database using the .ToString method (i.e. Wednesday) </p>
  
  <p>in the long run this will be inefficient so is there a way of associating that day (Wednesday) with a matching field in the <strong>Day</strong> table? and also then assign it to the correct ID? I would be doing this by using the below ERD:</p>
  
  <pre><code>  DayName    ID
    Monday      1
    Tuesday     2
    Wednesday   3
    Thursday    4
    Friday      5
    Saturday    6
    Sunday      7
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/97S4Q.png" alt="enter image description here"></p>