score:0

var emailevents = db.tblemailevents.asqueryable();
switch(myconstant)
{
    case constants.opened:
        emailevents = emailevents.where(t => t.strtype.toupper() == constants.opened_type;
    break;
    case constants.clicked:
        emailevents = emailevents.where(t => t.strtype.toupper() == constants.clicked_type;
    break;
    //etc
}

lstqueryevents = emailevents.where(t => t.tblsentemail.userid == userid)
    .where(t => t.tblsentemail.blnoutlookrec == true || t.tblsentemail.tblmerges.blnoutlookrec == true)
    .where(s => s.tblsentemail.tblrecipients.any(o => o.stremailaddress.contains(strsearch)) || s.tblsentemail.strsubject.contains(strsearch) || s.tblsentemail.tblrecipients.any(r => r.strdisplayname.contains(strsearch)))
    .orderbydescending(t => t.dtmevent)
    .take(intnumrecords)
    .tolist();

score:0

func<t, bool> predicate;
switch(constant)
{
    case constants.opened:
        predicate = (t t) => (t.strtype.toupper() == constants.opened_type);
        break;
    case constants.clicked:
        predicate = (t t) => (t.strtype.toupper() == constants.clicked_type);
        break;
}

lstqueryevents = db.tblemailevents
    .where(predicate)
    .where(t => t.tblsentemail.userid == userid)
    .where(t => t.tblsentemail.blnoutlookrec == true || t.tblsentemail.tblmerges.blnoutlookrec == true)
    .where(s => s.tblsentemail.tblrecipients.any(o => o.stremailaddress.contains(strsearch)) || s.tblsentemail.strsubject.contains(strsearch) || s.tblsentemail.tblrecipients.any(r => r.strdisplayname.contains(strsearch)))
    .orderbydescending(t => t.dtmevent)
    .take(intnumrecords)
    .tolist();

score:2

var lstqueryeventsquery = db.tblemailevents
        .where(t => t.tblsentemail.userid == userid)
        .where(t => t.tblsentemail.blnoutlookrec == true || t.tblsentemail.tblmerges.blnoutlookrec == true)
        .where(s => s.tblsentemail.tblrecipients.any(o => o.stremailaddress.contains(strsearch)) || s.tblsentemail.strsubject.contains(strsearch) || s.tblsentemail.tblrecipients.any(r => r.strdisplayname.contains(strsearch)));

switch(yourvariable)
{
    case constants.opened:
        lstqueryeventsquery = lstqueryeventsquery.where(t => t.strtype.toupper() == constants.opened_type)
        break;
    case constants.clicked:
        lstqueryeventsquery = lstqueryeventsquery.where(t => t.strtype.toupper() == constants.opened_type)
        break;
}

lstqueryevents = lstqueryeventsquery.orderbydescending(t => t.dtmevent)
    .take(intnumrecords)
    .tolist();