0

我在主页上有这个代码

 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?content=ContextB ContextE Con​​textJ

我想在 db 的 Facility 字段中搜索此值

我怎样才能做到这一点?(对不起,我的英语不好)

4

1 回答 1

0

I have the feeling your are looking for something along the lines of this query:

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

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

//...

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

(or instead of FacilityName some other property of Facility)

But I am not sure.

于 2013-05-17T22:32:03.890 回答