我是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