score:1

Accepted answer
if (inhouse != "inhouse")
                    r = r.where(p => p != inhouse);

score:-1

if (inhouse == "inhouse")
     r = r.where(p => p.contains(inhouse) && !p.contains("supplier") && !p.contains("group") && !p.contains("external"));

score:-1

        if (inhouse != "inhouse")
            r = r.where(p => p != "inhouse");

        if (supplier != "supplier")
            r = r.where(p => p != "supplier");

        if (groupw != "group")
            r = r.where(p => p != "group");

        if (external != "external")
            r = r.where(p => p != "external");

        r = r.orderby(p => p);

        return r.toarray();

score:0

string memberid = httpcontext.current.session["memberid"].tostring(); 
string inhouse = httpcontext.current.session["inhouse"].tostring();
string supplier = httpcontext.current.session["supplier"].tostring();

bool includeinhouse = (inhouse == "inhouse");
bool includesupplier = (supplier == "supplier");

myents autocomplete = new myents();

var r = from p in autocomplete.tblautocompletes
            where (p.memberid == memberid && p.locationid == locationid && p.acitem.contains(prefixtext))
            && (includeinhouse || (p.acitem != "inhouse"))
            && (includesupplier || (p.acitem != "supplier"))
            select p.acitem;

r.orderby(p => p.acitem);

return r.toarray();

More Query from same tag