我无法理解我在哪里出错,即使页面运行正常且没有错误,但查询仍然没有返回任何内容。这是代码:
public void loadresults()
{
JobDescription objjobdes = new JobDescription();
string search = Request.QueryString["result"].ToString();
var jobquery1 = from objjob in db.Jobs
where objjob.JobTitle == search
select objjob.JobTitle;
var eventquery1 = from objev in db.Events
where objev.Name == search
select objev.Name;
var profilequery1 = from objprofile in db.Profiles
where objprofile.FirstName == search
select objprofile.FirstName;
List<string> searchresult = new List<string>();
if (jobquery1.Count() > 0)
{
lvsearchdetails.DataSource = jobquery1.ToList();
lvsearchdetails.DataBind();
}
else if (eventquery1.Count() > 0)
{
lvsearchdetails.DataSource = eventquery1.ToList();
lvsearchdetails.DataBind();
}
else if (profilequery1.Count() > 0)
{
lvsearchdetails.DataSource = profilequery1.ToList();
lvsearchdetails.DataBind();
}
else
{
Response.Write("Your search did not match any results!");
}
}
在查询事物时,结果就是查询结果
SELECT [Distinct1].[C1] AS [C1] FROM ( SELECT DISTINCT [UnionAll1].[JobTitle] AS [C1] FROM (SELECT [Extent1].[JobTitle] AS [JobTitle] FROM [dbo].[Jobs] AS [Extent1] WHERE ( CAST(CHARINDEX([Extent1].[JobTitle], @p__linq__0) AS int)) > 0 UNION ALL SELECT @p__linq__3 AS [C1] FROM [dbo].[Jobs] AS [Extent2] WHERE @p__linq__1 LIKE @p__linq__2 ESCAPE N'~') AS [UnionAll1] ) AS [Distinct1]
任何形式的帮助都会很好,同时也不要苛刻我是初学者。