score:2

Accepted answer

That executes the same query 4 or 5 separate times, although connection pooling will reuse a single connection. Should be

var query = from e in ctx.bio_employee.Where(x => x.emp_id == emp_id)
             select new
             {
                  ta.ta_system
                 ,ta.bio_consent_flag
                 ,e.bio_consentform_rid
             };

var result = query.FirstOrDefault();

if (result != null) 
{
    vm.TASystem = result .ta_system;
    vm.bio_consent_flag = result .bio_consent_flag == null ? "N" : result .bio_consent_flag.Trim().ToUpper();
    vm.employee_bio_consentform_rid = result.bio_consentform_rid;
}

Related Articles