title: Insert Data using Linq from C#
body: <p>I have version table which contains version number and version ID. I need to get the version ID based on the Version number. How to achieve this in more efficient way ? </p>
  
  <pre><code>        using (PatchSyncDBDataContext patchSyncDB = new PatchSyncDBDataContext())
          {
              int versionID = (from version in patchSyncDB.AppPM_Versions
                               where version.StatusID != 0 &amp;&amp;
                               version.VersionNumber == versionNumber
                               select version.VersionId).First();
  
              int customerID = (from reqID in patchSyncDB.MasterRepTables
                                where reqID.rep_email == dtLoginUser
                                select reqID.rep_id).First();
  
              AppPM_Patch AppPM_Patches = new AppPM_Patch()
              {
                  PatchId = patchID,
                  IncidentId = incidentID,
                  VersionId = versionID,
                  RequestedUserId = customerID,
                  Emails = emailTo,
                  StartDateTime = dateTimes,
                  PatchStatus = patchStatus,
                  StatusID = 1,
                  SelectedProjects = selectedProjects
              };
              patchSyncDB.AppPM_Patches.InsertOnSubmit(AppPM_Patches);
              patchSyncDB.SubmitChanges();
          }
  </code></pre>