我的表格有版本编号和版本ID。 我需要根据版本编号获得该版本的ID。 如何以更有效的方式实现这一目标?
using (PatchSyncDBDataContext patchSyncDB = new PatchSyncDBDataContext())
{
int versionID = (from version in patchSyncDB.AppPM_Versions
where version.StatusID != 0 &&
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();
}