0

我在網頁如何搜索多keywork在LINQ查詢

CheckBox[] ch= new CheckBox[12]; 
       ch[0] = ChkContextA; 
       ch[1]= ChkContextB; 
       ch[2]= ChkContextC; 
       ch[3]= ChkContextD; 
       ch[4]= ChkContextE; 
       ch[5]= ChkContextF; 
       ch[6]= ChkContextG; 
       ch[7]= ChkContextH; 
       ch[8]= ChkContextI; 
       ch[9]= ChkContextJ; 
       ch[10]= ChkContextK; 
       ch[11]= ChiContextL; 
       for (int i = 0; i < 11; i++) 
        if (ch[i].Checked) search += ch[i].Text + " "; 
       Response.Redirect("SearchEstate.aspx?content="+search); 

此代碼,這個代碼在SearchEstate

var content = Request.QueryString["content"]; 
     RealEstateEntities db = new RealEstateEntities(); 

       var query = from O in db.Owners  
       join E in db.Estates on O.OwnerID equals E.OwnerID 
       join P in db.Properties on E.PropertyID equals P.PropertyID 
       where P.Facilities.Contains(content) 

       select new 
       { 
        regdate = E.RegisterDate, 
        region = E.Region, 
        Estype = E.EstateType, 
        Fac = P.Facilities, 
        deal = P.DealType, 
        price = P.TotalCost, 
        img = E.Picture, 
        addrss = O.Address, 
        area = P.Area, 
        tel = P.TellNum, 
        bed = P.RoomNum, 
        park = P.ParikingNum 
       }; 
    Repeater2.DataSource = query.OrderByDescending(x => x.regdate); 
    Repeater2.DataBind(); 

當用戶選中一些複選框「內容」例如有這樣的價值: SearchEstate.aspx?內容= ContextB ContextE Con​​textJ

我想在DB

在搜索領域的設備這一值210

我該怎麼做? (對不起,我英文不好)

回答

0

我中有你正在尋找沿此查詢線的東西的感覺:

var content = Request.QueryString["content"]; 

string[] contentArray = content.Split(' '); 

//... 

var query = //... 
      where P.Facilities.Any(f => contentArray.Contains(f.FacilityName)) 
      //... 

(或代替FacilityNameFacility一些其他財產)

但我不確定。