我是LINQ的新手。我有一個使用LINQ填充的GridView。我的LINQ語句正在從上一頁獲取查詢字符串。查詢字符串是字符串格式。以下是代碼:加入不在LINQ聲明中工作
protected void Page_Load(object sender, EventArgs e)
{
string getEntity = Request.QueryString["EntityID"];
int getIntEntity = Int32.Parse(getEntity);
OISLinqtoSQLDataContext db = new OISLinqtoSQLDataContext();
var tr = from r in db.Users
join s in db.Entities on r.UserID equals s.ID
where s.ID = Request.QueryString["EntityID"]
select new
{
//To Show Items in GridView!
};
GridView1.DataSource = tr;
GridView1.DataBind();
}
s.ID不等於QueryString。 S.ID是一種int類型,QS是一種字符串。我應該如何將此QS轉換爲整數?謝謝!
您已經將QueryString轉換爲int - 'getIntEntity'。只需在你的查詢中使用它。 – kevingessner 2011-03-23 15:46:35
是的,那是凱文。但是在我的JOIN中有一個錯誤顯示:錯誤\t連接子句中的一個表達式的類型不正確。在「加入」的調用中,類型推斷失敗。 – 2011-03-23 16:00:18