您好,
如果我在我的数据库中运行:
SELECT *
FROM
Ads AS a
INNER JOIN AdCategories AS ac
on (ac.Id = a.CategoryId)
INNER JOIN Location AS l
on (l.Id = a.UserLocationId)
WHERE
(l.LevelOrder LIKE '2/3/5/%') AND
(a.Title LIKE '%' OR a.Description LIKE '%') AND
a.InactivatedDate IS NULL AND
a.PublishedDate IS NOT NULL AND
a.EndDate >= '2012-02-04 17:01:37' AND
a.EndDate >= '2011-11-04 16:55:26' AND
ac.LevelOrder Like '7/15/33/36_%'
这将返回2行,但在使用Entity Framework
运行相同的命令时context.CreateQuery<Ad>(sqlCommand, parameters.ToArray());
output = ads.ToList();
我一无所获?
这就是SQL语句的样子:
SELECT VALUE a
FROM
Ads AS a
INNER JOIN AdCategories AS ac
on (ac.Id = a.CategoryId)
INNER JOIN Location AS l
on (l.Id = a.UserLocationId)
WHERE
(l.LevelOrder LIKE @locationLevelOrder0) AND
(a.Title LIKE @searchS OR a.Description LIKE @searchS) AND
a.InactivatedDate IS NULL AND
a.PublishedDate IS NOT NULL AND
a.EndDate >= @CurrentTime AND
a.EndDate >= @fetchAdsTo AND
ac.LevelOrder Like @categoryLevelOrder
参数如下所示:
LocationLevelOrder0 = 2/3/5/%
searchS = %
CurrentTime = {2012-02-04 17:31:34}
fetchAdsTo = {2011-11-04 17:31:34}
categoryLevelOrder = 7/15/33/36/_%
为什么我在SQL管理器中没有使用Entity Framework获得任何结果?选择价值代表什么?如果我删除它将会抛出异常?
答案 0 :(得分:1)
首先在查询中将LevelOrder与'7/15/33/36_%'
进行比较,在第二个中将7/15/33/36/_%
与另一个字符串进行比较。这是转录错误还是问题?